Permalink
Browse files

merge

  • Loading branch information...
2 parents 1c85885 + 6adc6e9 commit 25ac4d635ffff8c99af6fa11961ffbf65a0dd42e @contra contra committed Mar 1, 2014
Showing with 20 additions and 17 deletions.
  1. +16 −15 bin/gulp.js
  2. +1 −1 docs/writing-a-plugin/dealing-with-streams.md
  3. +1 −0 docs/writing-a-plugin/guidelines.md
  4. +2 −1 package.json
View
@@ -3,6 +3,7 @@
'use strict';
var gutil = require('gulp-util');
var prettyTime = require('pretty-hrtime');
+var chalk = require('chalk');
var semver = require('semver');
var archy = require('archy');
var Liftoff = require('liftoff');
@@ -14,11 +15,11 @@ var cli = new Liftoff({
});
cli.on('require', function (name) {
- gutil.log('Requiring external module', gutil.colors.magenta(name));
+ gutil.log('Requiring external module', chalk.magenta(name));
});
cli.on('requireFail', function (name) {
- gutil.log(gutil.colors.red('Failed to load external module'), gutil.colors.magenta(name));
+ gutil.log(chalk.red('Failed to load external module'), chalk.magenta(name));
});
cli.launch(handleArguments);
@@ -41,32 +42,32 @@ function handleArguments(env) {
}
if (!env.modulePath) {
- gutil.log(gutil.colors.red('No local gulp install found in'), gutil.colors.magenta(env.cwd));
- gutil.log(gutil.colors.red('Try running: npm install gulp'));
+ gutil.log(chalk.red('No local gulp install found in'), chalk.magenta(env.cwd));
+ gutil.log(chalk.red('Try running: npm install gulp'));
process.exit(1);
}
if (!env.configPath) {
- gutil.log(gutil.colors.red('No gulpfile found'));
+ gutil.log(chalk.red('No gulpfile found'));
process.exit(1);
}
// check for semver difference between cli and local installation
if (semver.gt(cliPackage.version, env.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', env.modulePackage.version));
+ gutil.log(chalk.red('Warning: gulp version mismatch:'));
+ gutil.log(chalk.red('Running gulp is', cliPackage.version));
+ gutil.log(chalk.red('Local gulp (installed in gulpfile dir) is', env.modulePackage.version));
}
var gulpFile = require(env.configPath);
- gutil.log('Using gulpfile', gutil.colors.magenta(env.configPath));
+ gutil.log('Using gulpfile', chalk.magenta(env.configPath));
var gulpInst = require(env.modulePath);
logEvents(gulpInst);
if (process.cwd() !== env.cwd) {
process.chdir(env.cwd);
- gutil.log('Working directory changed to', gutil.colors.magenta(env.cwd));
+ gutil.log('Working directory changed to', chalk.magenta(env.cwd));
}
process.nextTick(function () {
@@ -79,7 +80,7 @@ function handleArguments(env) {
function logTasks(gulpFile, localGulp) {
var tree = taskTree(localGulp.tasks);
- tree.label = 'Tasks for ' + gutil.colors.magenta(gulpFile);
+ tree.label = 'Tasks for ' + chalk.magenta(gulpFile);
archy(tree).split('\n').forEach(function (v) {
if (v.trim().length === 0) return;
gutil.log(v);
@@ -96,22 +97,22 @@ function formatError(e) {
// wire up logging events
function logEvents(gulpInst) {
gulpInst.on('task_start', function (e) {
- gutil.log('Starting', "'" + gutil.colors.cyan(e.task) + "'...");
+ gutil.log('Starting', "'" + chalk.cyan(e.task) + "'...");
});
gulpInst.on('task_stop', function (e) {
var time = prettyTime(e.hrDuration);
- gutil.log('Finished', "'" + gutil.colors.cyan(e.task) + "'", 'after', gutil.colors.magenta(time));
+ gutil.log('Finished', "'" + chalk.cyan(e.task) + "'", 'after', chalk.magenta(time));
});
gulpInst.on('task_err', function (e) {
var msg = formatError(e);
var time = prettyTime(e.hrDuration);
- gutil.log("'" + gutil.colors.cyan(e.task) + "'", 'errored after', gutil.colors.magenta(time), gutil.colors.red(msg));
+ gutil.log("'" + chalk.cyan(e.task) + "'", 'errored after', chalk.magenta(time), chalk.red(msg));
});
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(chalk.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);
});
@@ -2,7 +2,7 @@
> It is highly recommended to write plugins supporting streams. Here is some information on creating a gulp plugin that supports streams.
-> Make sure to follow the best practice regarging error handling and add the line that make the gulp plugin re-emit the first error catched during the transformation of the content
+> Make sure to follow the best practice regarding error handling and add the line that make the gulp plugin re-emit the first error catched during the transformation of the content
[Writing a Plugin](README.md) > Writing stream based plugins
@@ -29,6 +29,7 @@
- If file.contents is a Stream and you don't support that just emit an error
- Do not buffer a stream to shoehorn your plugin to work with streams. This will cause horrible things to happen.
1. Do not pass the `file` object downstream until you are done with it
+1. Use [`file.clone()`](https://github.com/wearefractal/vinyl#clone) when cloning a file or creating a new one based on a file.
1. Use modules from our [recommended modules page](recommended-modules.md) to make your life and ours easier
1. Do NOT require `gulp` as a dependency or peerDependency
- There is no reason you should have to do this and it will cause problems if you do
View
@@ -30,7 +30,8 @@
"semver": "^2.2.1",
"archy": "^0.0.2",
"deprecated": "^0.0.1",
- "liftoff": "^0.9.3"
+ "liftoff": "^0.9.3",
+ "chalk": "^0.4.0"
},
"devDependencies": {
"mocha": "^1.17.0",

0 comments on commit 25ac4d6

Please sign in to comment.