Comparing version 2.0.1 to 2.1.0
59
index.js
@@ -64,5 +64,2 @@ 'use strict'; | ||
// Set up event listeners for logging temporarily. | ||
toConsole(log, opts); | ||
cli.on('require', function(name) { | ||
@@ -72,4 +69,10 @@ log.info('Requiring external module', ansi.magenta(name)); | ||
cli.on('requireFail', function(name) { | ||
log.error(ansi.red('Failed to load external module'), ansi.magenta(name)); | ||
cli.on('requireFail', function(name, error) { | ||
log.warn( | ||
ansi.yellow('Failed to load external module'), | ||
ansi.magenta(name) | ||
); | ||
if (error) { | ||
log.warn(ansi.yellow(error.toString())); | ||
} | ||
}); | ||
@@ -85,3 +88,3 @@ | ||
function run() { | ||
cli.launch({ | ||
cli.prepare({ | ||
cwd: opts.cwd, | ||
@@ -91,3 +94,14 @@ configPath: opts.gulpfile, | ||
completion: opts.completion, | ||
}, handleArguments); | ||
}, function(env) { | ||
var cfgLoadOrder = ['home', 'cwd']; | ||
var cfg = loadConfigFiles(env.configFiles['.gulp'], cfgLoadOrder); | ||
opts = mergeConfigToCliFlags(opts, cfg); | ||
env = mergeConfigToEnvFlags(env, cfg, opts); | ||
env.configProps = cfg; | ||
// Set up event listeners for logging again after configuring. | ||
toConsole(log, opts); | ||
cli.execute(env, env.nodeFlags, handleArguments); | ||
}); | ||
} | ||
@@ -99,6 +113,2 @@ | ||
function handleArguments(env) { | ||
var cfgLoadOrder = ['home', 'cwd']; | ||
var cfg = loadConfigFiles(env.configFiles['.gulp'], cfgLoadOrder); | ||
opts = mergeConfigToCliFlags(opts, cfg); | ||
env = mergeConfigToEnvFlags(env, cfg); | ||
@@ -113,5 +123,2 @@ // This translates the --continue flag in gulp | ||
// Set up event listeners for logging again after configuring. | ||
toConsole(log, opts); | ||
if (opts.help) { | ||
@@ -122,6 +129,7 @@ parser.showHelp(console.log); | ||
// Anything that needs to print outside of the logging mechanism should use console.log | ||
if (opts.version) { | ||
log.info('CLI version', cliVersion); | ||
console.log('CLI version', cliVersion); | ||
if (env.modulePackage && typeof env.modulePackage.version !== 'undefined') { | ||
log.info('Local version', env.modulePackage.version); | ||
console.log('Local version', env.modulePackage.version); | ||
} | ||
@@ -149,7 +157,19 @@ exit(0); | ||
if (!env.modulePath) { | ||
var missingNodeModules = | ||
fs.existsSync(path.join(env.cwd, 'package.json')) | ||
&& !fs.existsSync(path.join(env.cwd, 'node_modules')); | ||
var missingGulpMessage = | ||
missingNodeModules | ||
? 'Local modules not found in' | ||
: 'Local gulp not found in'; | ||
log.error( | ||
ansi.red('Local gulp not found in'), | ||
ansi.red(missingGulpMessage), | ||
ansi.magenta(tildify(env.cwd)) | ||
); | ||
log.error(ansi.red('Try running: npm install gulp')); | ||
var installCommand = | ||
missingNodeModules | ||
? 'npm install' | ||
: 'npm install gulp'; | ||
log.error(ansi.red('Try running: ' + installCommand)); | ||
exit(1); | ||
@@ -183,3 +203,4 @@ } | ||
// Load and execute the CLI version | ||
require(path.join(__dirname, '/lib/versioned/', range, '/'))(opts, env, cfg); | ||
var versionedDir = path.join(__dirname, '/lib/versioned/', range, '/'); | ||
require(versionedDir)(opts, env, env.configProps); | ||
} |
@@ -18,2 +18,3 @@ 'use strict'; | ||
bold: hasColors ? colors.bold : noColor, | ||
yellow: hasColors ? colors.yellow : noColor, | ||
}; | ||
@@ -20,0 +21,0 @@ |
@@ -65,2 +65,3 @@ 'use strict'; | ||
requiresArg: true, | ||
default: undefined, // To detect if this cli option is specified. | ||
desc: ansi.gray( | ||
@@ -71,2 +72,3 @@ 'Specify the depth of the task dependency tree.'), | ||
type: 'boolean', | ||
default: undefined, // To detect if this cli option is specified. | ||
desc: ansi.gray( | ||
@@ -78,2 +80,3 @@ 'Reduce the output of task dependency tree by printing ' + | ||
type: 'boolean', | ||
default: undefined, // To detect if this cli option is specified. | ||
desc: ansi.gray( | ||
@@ -97,2 +100,3 @@ 'Will sort top tasks of task dependency tree.'), | ||
type: 'boolean', | ||
default: undefined, // To detect if this cli option is specified. | ||
desc: ansi.gray( | ||
@@ -103,2 +107,3 @@ 'Suppress all gulp logging.'), | ||
type: 'boolean', | ||
default: undefined, // To detect if this cli option is specified. | ||
desc: ansi.gray( | ||
@@ -109,2 +114,3 @@ 'Continue execution of tasks upon failure.'), | ||
type: 'boolean', | ||
default: undefined, // To detect if this cli option is specified. | ||
desc: ansi.gray( | ||
@@ -117,3 +123,3 @@ 'Run tasks given on the CLI in series (the default is parallel).'), | ||
count: true, | ||
// Can't use `default` because it seems to be off by one | ||
default: undefined, // To detect if this cli option is specified. | ||
desc: ansi.gray( | ||
@@ -120,0 +126,0 @@ 'Set the loglevel. -L for least verbose and -LLLL for most verbose. ' + |
@@ -16,5 +16,11 @@ 'use strict'; | ||
function mergeConfigToCliFlags(opt, config) { | ||
return copyProps(config, opt, fromTo); | ||
return copyProps(config, opt, fromTo, defaults); | ||
} | ||
function defaults(cfgInfo, optInfo) { | ||
if (optInfo.value === undefined) { | ||
return cfgInfo.value; | ||
} | ||
} | ||
module.exports = mergeConfigToCliFlags; |
@@ -9,15 +9,38 @@ 'use strict'; | ||
configBase: 'flags.gulpfile', | ||
require: 'flags.require', | ||
nodeFlags: 'flags.nodeFlags', | ||
}; | ||
function mergeConfigToEnvFlags(env, config) { | ||
return copyProps(env, config, toFrom, convert, true); | ||
} | ||
function mergeConfigToEnvFlags(env, config, cliOpts) { | ||
// This must reverse because `flags.gulpfile` determines 2 different properties | ||
var reverse = true; | ||
return copyProps(env, config, toFrom, convert, reverse); | ||
function convert(configInfo, envInfo) { | ||
if (envInfo.keyChain === 'configBase') { | ||
return path.dirname(configInfo.value); | ||
function convert(configInfo, envInfo) { | ||
if (envInfo.keyChain === 'configBase') { | ||
if (cliOpts.gulpfile === undefined) { | ||
return path.dirname(configInfo.value); | ||
} | ||
return; | ||
} | ||
if (envInfo.keyChain === 'configPath') { | ||
if (cliOpts.gulpfile === undefined) { | ||
return configInfo.value; | ||
} | ||
return; | ||
} | ||
if (envInfo.keyChain === 'require') { | ||
return [].concat(envInfo.value, configInfo.value); | ||
} | ||
if (envInfo.keyChain === 'nodeFlags') { | ||
return [].concat(configInfo.value || []); | ||
} | ||
return configInfo.value; | ||
} | ||
return configInfo.value; | ||
} | ||
module.exports = mergeConfigToEnvFlags; |
@@ -35,3 +35,3 @@ 'use strict'; | ||
// not desired. | ||
if (opts.tasksSimple || opts.silent) { | ||
if (opts.tasksSimple || opts.tasksJson || opts.help || opts.version || opts.silent) { | ||
// Keep from crashing process when silent. | ||
@@ -38,0 +38,0 @@ log.on('error', noop); |
@@ -58,3 +58,3 @@ 'use strict'; | ||
tree = taskTree(gulpInst.tasks); | ||
if (config.description && isString(config.description)) { | ||
if (config.description && typeof config.description === 'string') { | ||
tree.label = config.description; | ||
@@ -61,0 +61,0 @@ } else { |
@@ -26,3 +26,3 @@ 'use strict'; | ||
}); | ||
return { label: 'Tasks', nodes: arr, }; | ||
return { label: 'Tasks', nodes: arr }; | ||
}; |
{ | ||
"name": "gulp-cli", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Command line interface for gulp", | ||
@@ -26,3 +26,3 @@ "author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)", | ||
"scripts": { | ||
"lint": "eslint . && jscs index.js bin/ lib/ test/", | ||
"lint": "eslint .", | ||
"prepublish": "marked-man --name gulp docs/CLI.md > gulp.1", | ||
@@ -45,3 +45,3 @@ "pretest": "npm run lint", | ||
"isobject": "^3.0.1", | ||
"liftoff": "^2.5.0", | ||
"liftoff": "^3.1.0", | ||
"matchdep": "^2.0.0", | ||
@@ -58,13 +58,11 @@ "mute-stdout": "^1.0.0", | ||
"babel-register": "^6.5.1", | ||
"coveralls": "^2.7.0", | ||
"eslint": "^1.7.3", | ||
"eslint-config-gulp": "^2.0.0", | ||
"coveralls": "^3.0.3", | ||
"eslint": "^2.13.1", | ||
"eslint-config-gulp": "^3.0.1", | ||
"expect": "^1.20.2", | ||
"gulp": "^4.0.0", | ||
"gulp-test-tools": "^0.6.1", | ||
"jscs": "^3.0.7", | ||
"jscs-preset-gulp": "^1.0.0", | ||
"marked-man": "^0.2.1", | ||
"mocha": "^3.2.0", | ||
"nyc": "^11.4.1", | ||
"nyc": "^13.3.0", | ||
"rimraf": "^2.6.1" | ||
@@ -71,0 +69,0 @@ }, |
@@ -111,2 +111,4 @@ <p align="center"> | ||
| flags.series | Run tasks given on the CLI in series (the default is parallel) | | ||
| flags.require | An array of modules to require before running the gulpfile. Any relative paths will be resolved against the `--cwd` directory (if you don't want that behavior, use absolute paths) | | ||
| flags.nodeFlags | An array of flags used to forcibly respawn the process upon startup. For example, if you always want your gulpfiles to run in node's harmony mode, you can set `--harmony` here | | ||
@@ -151,3 +153,3 @@ ## Flags | ||
<td></td> | ||
<td>Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here.</td> | ||
<td>Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires (including the `--require` flag) will be from here.</td> | ||
</tr> | ||
@@ -154,0 +156,0 @@ <tr> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
57345
12
1314
241
+ Addedfindup-sync@3.0.0(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedliftoff@3.1.0(transitive)
- Removedliftoff@2.5.0(transitive)
Updatedliftoff@^3.1.0