• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

electrode-io/electrode-gulp-helper: Helper functions for using gulp

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

electrode-io/electrode-gulp-helper

开源软件地址(OpenSource Url):

https://github.com/electrode-io/electrode-gulp-helper

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

electrode-gulp-helper NPM version Build Status Dependency Status

Helper functions for managing gulp tasks loading and executing.

Usage

Install:

npm install electrode-gulp-helper --save-dev
const gulpHelper = require("electrode-gulp-helper");

gulpHelper.loadTasks( tasks );

API

loadTasks

gulpHelper.loadTasks( tasks, gulp )

gulp - pass in gulp instance. If not provided, then it's attempted with require("gulp").

tasks - should follow the spec below:

{
    "task1-name": taskData,
    "task2-name": taskData
}

Where taskData can be a string, function, array, or object.

taskData

taskData specifies a task for gulp. It can be a string, function, array, or object.

string

If it's a string, then it's treated as a shell command and executed using exec.

function

If it's a function, then it's to be called by gulp when it executes the task. It's passed to gulp like this.

gulp.task( taskName, description, taskData );

The description support is added with the module gulp-help

If taskName starts with . then the description is false and disabled, else it's an empty string "". You can specify description if you use object for taskData.

array

If it's an array, it specifies a list of tasks or group of tasks in a subarray to be executed sequentially. A group of tasks will be executed in parallel.

Example: [ "task1", "task2", [ "p-task1", "p-task2" ], "task3" ]

task1 and task2 are executed in sequence first, and then p-task1 and p-task2 are executed in parallel, and finally task3.

The sequential execution support is from run-sequence.

The array is passed to run-sequence like this, with description being a stringified copy of the array.

gulp.task( taskName, description, () => {
    runSequence.use(gulp).apply(null, taskData);
});

object

If it's an object, it should follow this spec:

{
    name: "task-name",   // optional - use this instead of the key field for task name
    dep: array,          // optional - list of dependent tasks - follow definition above
    desc: "description", // optional
    task: string|function|array // follow the definitions above
}

If the description field desc is false, then the task is not listed in help. If it's undefined, then "" will be used.

The dep specified a dependent array of tasks following the array spec above, to be executed before the actual task. It is added to gulp like below, with a new delegate task using the same name with a postfix $deps$.

gulp.task( `${taskName}$deps$`, false, () => runSequence.use(gulp).apply(null, taskData.dep) );

exec

gulpHelper.exec( shellCommand, [callback] );

Use shelljs exec to execute shellCommand.

If callback is provided, it will be called as follows:

callback( code !== 0 ? new Error("...") : undefined, { stdout, stderr } )

stdout and stderr is also set in the error object.

If no callback is provided, it will return a Promise that rejects with the error or resolve with { stdout, stderr }.

shellCommand can be combination of multiple strings and arrays. Array is joined with " " into strings. All final strings are joined with " ".

envPath.addToFront

gulpHelper.envPath.addToFront(path);

Add path to the front of process.env.PATH. If it already exists, then it is moved to the front.

envPath.addToEnd

gulpHelper.envPath.addToEnd(path);

Add path to the end of process.env.PATH. If it already exists, then it is moved to the end.

envPath.add

gulpHelper.envPath.add(path);

If path doesn't exist in process.env.PATH then it's added to the end.

Built with ❤️ by Team Electrode @WalmartLabs.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap