Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CLI cleanup

  • Loading branch information...
commit eaf8229dac3eefe7f1a97ec68651e01fe44072dd 1 parent b5404f8
@contra contra authored
Showing with 41 additions and 39 deletions.
  1. +2 −2 CONTRIBUTING.md
  2. +37 −35 bin/gulp.js
  3. +1 −1  docs/CLI.md
  4. +1 −1  package.json
View
4 CONTRIBUTING.md
@@ -14,7 +14,7 @@ In particular, this community seeks the following types of contributions:
- ideas: participate in an Issues thread or start your own to have your voice
heard.
-- resources: submit a PR to add to [docs README.md](docs/README.md) with links to related content
+- resources: submit a PR to add to [docs README.md](/docs/README.md) with links to related content
- outline sections: help us ensure that this repository is comprehensive. if
there is a topic that is overlooked, please add it, even if it is just a stub
in the form of a header and single sentence. Initially, most things fall into
@@ -77,4 +77,4 @@ on what we're actually doing, not wandering off into too much imaginary stuff.
# Frequently Asked Questions
-See [the FAQ docs page](docs/FAQ.md)
+See [the FAQ docs page](/docs/FAQ.md)
View
72 bin/gulp.js
@@ -18,14 +18,16 @@ cli.on('require', function (name) {
});
cli.on('requireFail', function (name) {
- gutil.log('Failed to load external module', gutil.colors.magenta(name));
+ gutil.log(gutil.colors.red('Failed to load external module'), gutil.colors.magenta(name));
});
cli.launch(function () {
+ handleArguments(this);
+});
- var argv = this.argv;
+function handleArguments(args) {
+ var argv = args.argv;
var cliPackage = require('../package');
- // TODO: drop argv.v in the next breaking release
var versionFlag = argv.v || argv.V || argv.version;
var tasksFlag = argv.T || argv.tasks;
var tasks = argv._;
@@ -33,82 +35,82 @@ cli.launch(function () {
if (versionFlag) {
gutil.log('CLI version', cliPackage.version);
- if (this.localPackage) {
- gutil.log('Local version', this.modulePackage.version);
+ if (args.localPackage) {
+ gutil.log('Local version', args.modulePackage.version);
}
process.exit(0);
}
- if (!this.modulePath) {
- gutil.log(gutil.colors.red('No local gulp install found in'), gutil.colors.magenta(this.cwd));
+
+ if (!args.modulePath) {
+ gutil.log(gutil.colors.red('No local gulp install found in'), gutil.colors.magenta(args.cwd));
gutil.log(gutil.colors.red('Try running: npm install gulp'));
process.exit(1);
}
- if (!this.configPath) {
+ if (!args.configPath) {
gutil.log(gutil.colors.red('No gulpfile found'));
process.exit(1);
}
// check for semver difference between cli and local installation
- if (semver.gt(cliPackage.version, this.modulePackage.version)) {
- gutil.log(gutil.colors.red('gulp version mismatch:'));
+ if (semver.gt(cliPackage.version, args.modulePackage.version)) {
+ gutil.log(gutil.colors.red('Warning: gulp version mismatch:'));
gutil.log(gutil.colors.red('Running gulp is', cliPackage.version));
- gutil.log(gutil.colors.red('Local gulp (installed in gulpfile dir) is', this.modulePackage.version));
+ gutil.log(gutil.colors.red('Local gulp (installed in gulpfile dir) is', args.modulePackage.version));
}
- var Gulpfile = require(this.configPath);
- gutil.log('Using file', gutil.colors.magenta(this.configPath));
+ var gulpFile = require(args.configPath);
+ gutil.log('Using gulpfile', gutil.colors.magenta(args.configPath));
- var Gulp = require(this.modulePath);
- logEvents(Gulp);
- process.chdir(this.cwd);
- gutil.log('Working directory changed to', gutil.colors.magenta(this.cwd));
+ var gulpInst = require(args.modulePath);
+ logEvents(gulpInst);
+ process.chdir(args.cwd);
+ gutil.log('Working directory changed to', gutil.colors.magenta(args.cwd));
- process.nextTick(function(){
+ process.nextTick(function () {
if (tasksFlag) {
- return logTasks(Gulpfile, Gulp);
+ return logTasks(gulpFile, gulpInst);
}
+ gulpInst.start.apply(gulpInst, toRun);
});
-
- Gulp.start.apply(Gulp, toRun);
-});
+}
function logTasks(gulpFile, localGulp) {
var tree = taskTree(localGulp.tasks);
- tree.label = 'Tasks for '+gutil.colors.magenta(gulpFile);
- archy(tree).split('\n').forEach(function(v){
+ tree.label = 'Tasks for ' + gutil.colors.magenta(gulpFile);
+ archy(tree).split('\n').forEach(function (v) {
if (v.trim().length === 0) return;
gutil.log(v);
});
}
// format orchestrator errors
-function formatError (e) {
+function formatError(e) {
if (!e.err) return e.message;
if (e.err.message) return e.err.message;
return JSON.stringify(e.err);
}
// wire up logging events
-function logEvents(gulp) {
- gulp.on('task_start', function(e){
- gutil.log('Running', "'"+gutil.colors.cyan(e.task)+"'...");
+function logEvents(gulpInst) {
+ gulpInst.on('task_start', function (e) {
+ gutil.log('Running', "'" + gutil.colors.cyan(e.task) + "'...");
});
- gulp.on('task_stop', function(e){
+ gulpInst.on('task_stop', function (e) {
var time = prettyTime(e.hrDuration);
- gutil.log('Finished', "'"+gutil.colors.cyan(e.task)+"'", 'in', gutil.colors.magenta(time));
+ gutil.log('Finished', "'" + gutil.colors.cyan(e.task) + "'", 'in', gutil.colors.magenta(time));
});
- gulp.on('task_err', function(e){
+ gulpInst.on('task_err', function (e) {
var msg = formatError(e);
var time = prettyTime(e.hrDuration);
- gutil.log('Errored', "'"+gutil.colors.cyan(e.task)+"'", 'in', gutil.colors.magenta(time), gutil.colors.red(msg));
+ gutil.log('Errored', "'" + gutil.colors.cyan(e.task) + "'", 'in', gutil.colors.magenta(time), gutil.colors.red(msg));
});
- gulp.on('task_not_found', function(err){
- gutil.log(gutil.colors.red("Task '"+err.task+"' was not defined in your gulpfile but you tried to run it."));
+ gulpInst.on('task_not_found', function (err) {
+ gutil.log(gutil.colors.red("Task '" + err.task + "' was not defined in your gulpfile but you tried to run it."));
gutil.log('Please check the documentation for proper gulpfile formatting.');
process.exit(1);
});
-}
+}
View
2  docs/CLI.md
@@ -4,7 +4,7 @@
gulp has very few flags to know about. All other flags are for tasks to use if needed.
-- `-v` or `--version` will display the global and local gulp versions
+- `-v` `-V` or `--version` will display the global and local gulp versions
- `--require <module path>` will require a module before running the gulpfile. This is useful for transpilers but also has other applications. You can use multiple `--require` flags
- `--gulpfile <gulpfile path>` manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well.
- `--cwd <dir path>` manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here.
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "gulp",
"description": "The streaming build system",
- "version": "3.5.3",
+ "version": "3.5.4",
"homepage": "http://github.com/wearefractal/gulp",
"repository": "git://github.com/wearefractal/gulp.git",
"author": "Fractal <contact@wearefractal.com> (http://wearefractal.com/)",
Please sign in to comment.
Something went wrong with that request. Please try again.