Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add missing spaces into function declarations #326

Merged
merged 2 commits into from

3 participants

@t3chnoboy

There is no consistency in putting space before parentheses in anonymous function declaration.
For example in README.MD Sample gulpfile:
At line 23 there is no space before ()

gulp.task('images', function() {

At line 31 there is a space

gulp.task('watch', function () {

I've added missing spaces according to code conventions
There were also some missing spaces between ')' and '{'. I've added them too.

@contra
Owner

Yeah thats what happens when a bunch of people are submitting docs PRs

I use this style guide btw http://nodeguide.com/style.html

@t3chnoboy

Looks like there are no spaces between function and () in http://nodeguide.com/style.html
Should I stick with 'function()' and resubmit PR?

@contra
Owner

@t3chnoboy sure, or just modify this existing one (commit to the pr branch)

@t3chnoboy

done!

@contra contra merged commit 4618b32 into from
@contra
Owner

@t3chnoboy Thanks!

@tomasdev

What is the styleguide?

Owner

@tomasdev felixge's

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  README.md
@@ -50,7 +50,7 @@ gulp.task('images', function() {
});
// Rerun the task when a file changes
-gulp.task('watch', function () {
+gulp.task('watch', function() {
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.images, ['images']);
});
View
16 bin/gulp.js
@@ -14,11 +14,11 @@ var cli = new Liftoff({
completions: require('../lib/completion')
});
-cli.on('require', function (name) {
+cli.on('require', function(name) {
gutil.log('Requiring external module', chalk.magenta(name));
});
-cli.on('requireFail', function (name) {
+cli.on('requireFail', function(name) {
gutil.log(chalk.red('Failed to load external module'), chalk.magenta(name));
});
@@ -70,7 +70,7 @@ function handleArguments(env) {
gutil.log('Working directory changed to', chalk.magenta(env.cwd));
}
- process.nextTick(function () {
+ process.nextTick(function() {
if (tasksFlag) {
return logTasks(gulpFile, gulpInst);
}
@@ -81,7 +81,7 @@ function handleArguments(env) {
function logTasks(gulpFile, localGulp) {
var tree = taskTree(localGulp.tasks);
tree.label = 'Tasks for ' + chalk.magenta(gulpFile);
- archy(tree).split('\n').forEach(function (v) {
+ archy(tree).split('\n').forEach(function(v) {
if (v.trim().length === 0) return;
gutil.log(v);
});
@@ -96,22 +96,22 @@ function formatError(e) {
// wire up logging events
function logEvents(gulpInst) {
- gulpInst.on('task_start', function (e) {
+ gulpInst.on('task_start', function(e) {
gutil.log('Starting', "'" + chalk.cyan(e.task) + "'...");
});
- gulpInst.on('task_stop', function (e) {
+ gulpInst.on('task_stop', function(e) {
var time = prettyTime(e.hrDuration);
gutil.log('Finished', "'" + chalk.cyan(e.task) + "'", 'after', chalk.magenta(time));
});
- gulpInst.on('task_err', function (e) {
+ gulpInst.on('task_err', function(e) {
var msg = formatError(e);
var time = prettyTime(e.hrDuration);
gutil.log("'" + chalk.cyan(e.task) + "'", 'errored after', chalk.magenta(time), chalk.red(msg));
});
- gulpInst.on('task_not_found', function (err) {
+ gulpInst.on('task_not_found', function(err) {
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);
View
6 docs/API.md
@@ -146,13 +146,13 @@ So this example would look like this:
var gulp = require('gulp');
// takes in a callback so the engine knows when it'll be done
-gulp.task('one', function (cb) {
+gulp.task('one', function(cb) {
// do stuff -- async or otherwise
cb(err); // if err is not null and not undefined, the run will stop, and note that it failed
});
// identifies a dependent task must be complete before this one begins
-gulp.task('two', ['one'], function () {
+gulp.task('two', ['one'], function() {
// task 'one' is done now
});
@@ -183,7 +183,7 @@ Names of task(s) to run when a file changes, added with `gulp.task()`
```javascript
var watcher = gulp.watch('js/**/*.js', ['uglify','reload']);
-watcher.on('change', function(event){
+watcher.on('change', function(event) {
console.log('File '+event.path+' was '+event.type+', running tasks...');
});
```
View
2  docs/getting-started.md
@@ -17,7 +17,7 @@ npm install --save-dev gulp
```javascript
var gulp = require('gulp');
-gulp.task('default', function(){
+gulp.task('default', function() {
// place code for your default task here
});
```
View
2  docs/recipes/combining-streams-to-handle-errors.md
@@ -30,4 +30,4 @@ gulp.task('test', function() {
return combined;
});
-```
+```
View
2  docs/recipes/fast-browserify-builds-with-watchify.md
@@ -20,7 +20,7 @@ var gulp = require('gulp')
var source = require('vinyl-source-stream')
var watchify = require('watchify')
-gulp.task('watch', function () {
+gulp.task('watch', function() {
var bundler = watchify('./src/index.js');
// Optionally, you can apply transforms
View
4 docs/recipes/mocha-test-runner-with-gulp.md
@@ -29,7 +29,7 @@ var mocha = require('gulp-mocha');
var batch = require('gulp-batch');
var gutil = require('gulp-util');
-gulp.task('mocha', function () {
+gulp.task('mocha', function() {
return gulp.src(['test/*.js'], { read: false })
.pipe(mocha({ reporter: 'list' }))
.on('error', gutil.log);
@@ -50,7 +50,7 @@ var mocha = require('gulp-mocha');
var watch = require('gulp-watch');
var gutil = require('gulp-util')
-gulp.task('mocha', function () {
+gulp.task('mocha', function() {
return gulp.src(['test/*.js'], { read: false })
.pipe(mocha({ reporter: 'list' }))
.on('error', gutil.log);
View
2  docs/recipes/only-pass-through-changed-files.md
@@ -14,7 +14,7 @@ var uglify = require('gulp-uglify');
var SRC = 'src/*.js';
var DEST = 'dist';
-gulp.task('default', function () {
+gulp.task('default', function() {
return gulp.src(SRC)
// the `changed` task needs to know the destination directory
// upfront to be able to figure out which files changed
View
2  docs/recipes/pass-params-from-cli.md
@@ -14,7 +14,7 @@ var uglify = require('gulp-uglify');
var isProduction = args.type === 'production';
-gulp.task('scripts', function () {
+gulp.task('scripts', function() {
return gulp.src('**/*.js')
.pipe(gulpif(isProduction, uglify())) // only minify if production
.pipe(gulp.dest('dist'));
View
4 docs/recipes/running-task-steps-per-folder.md
@@ -25,9 +25,9 @@ var uglify = require('gulp-uglify');
var scriptsPath = './src/scripts/';
-function getFolders(dir){
+function getFolders(dir) {
return fs.readdirSync(dir)
- .filter(function(file){
+ .filter(function(file) {
return fs.statSync(path.join(dir, file)).isDirectory();
});
}
View
4 docs/recipes/running-tasks-in-series.md
@@ -19,13 +19,13 @@ So this example would look like this:
var gulp = require('gulp');
// takes in a callback so the engine knows when it'll be done
-gulp.task('one', function (cb) {
+gulp.task('one', function(cb) {
// do stuff -- async or otherwise
cb(err); // if err is not null and not undefined, the orchestration will stop, and 'two' will not run
});
// identifies a dependent task must be complete before this one begins
-gulp.task('two', ['one'], function () {
+gulp.task('two', ['one'], function() {
// task 'one' is done now
});
View
2  docs/recipes/sharing-streams-with-stream-factories.md
@@ -65,4 +65,4 @@ gulp.task('coffee', function() {
});
```
-You can see we split out our javascript pipeline (jshint + uglify) that was being reused in multiple tasks into a factory. These factories can be reused in as many tasks as you want. You can also nest factories and you can chain factories together for great effect. Splitting out each shared pipeline also gives you one central location to modify if you decide to change up your workflow.
+You can see we split out our javascript pipeline (jshint + uglify) that was being reused in multiple tasks into a factory. These factories can be reused in as many tasks as you want. You can also nest factories and you can chain factories together for great effect. Splitting out each shared pipeline also gives you one central location to modify if you decide to change up your workflow.
View
2  docs/recipes/using-external-config-file.md
@@ -41,7 +41,7 @@ function doStuff(cfg) {
.pipe(gulp.dest(cfg.dest));
}
-gulp.task('dry', function () {
+gulp.task('dry', function() {
doStuff(config.desktop);
doStuff(config.mobile);
});
View
6 docs/recipes/using-multiple-sources-in-one-task.md
@@ -25,7 +25,7 @@ var gulp = require('gulp');
var concat = require('gulp-concat');
var streamqueue = require('streamqueue');
-gulp.task('default', function () {
+gulp.task('default', function() {
return streamqueue({ objectMode: true },
gulp.src('foo/*'),
gulp.src('bar/*')
@@ -36,7 +36,7 @@ gulp.task('default', function () {
// ... or ...
-gulp.task('default', function () {
+gulp.task('default', function() {
var stream = streamqueue({ objectMode: true });
stream.queue(gulp.src('foo/*'));
stream.queue(gulp.src('bar/*'));
@@ -44,4 +44,4 @@ gulp.task('default', function () {
.pipe(concat('result.txt'))
.pipe(gulp.dest('build'));
});
-```
+```
View
4 docs/writing-a-plugin/dealing-with-streams.md
@@ -24,7 +24,7 @@ function prefixStream(prefixText) {
return stream;
}
-// Plugin level function (dealing with files)
+// Plugin level function(dealing with files)
function gulpPrefixer(prefixText) {
if (!prefixText) {
@@ -33,7 +33,7 @@ function gulpPrefixer(prefixText) {
prefixText = new Buffer(prefixText); // allocate ahead of time
// Creating a stream through which each file will pass
- var stream = through.obj(function (file, enc, callback) {
+ var stream = through.obj(function(file, enc, callback) {
if (file.isNull()) {
this.push(file); // Do nothing if no contents
return callback();
View
4 docs/writing-a-plugin/guidelines.md
@@ -59,7 +59,7 @@ function prefixStream(prefixText) {
return stream;
}
-// Plugin level function (dealing with files)
+// Plugin level function(dealing with files)
function gulpPrefixer(prefixText) {
if (!prefixText) {
@@ -68,7 +68,7 @@ function gulpPrefixer(prefixText) {
prefixText = new Buffer(prefixText); // allocate ahead of time
// Creating a stream through which each file will pass
- var stream = through.obj(function (file, enc, callback) {
+ var stream = through.obj(function(file, enc, callback) {
if (file.isNull()) {
this.push(file); // Do nothing if no contents
return callback();
View
18 docs/writing-a-plugin/testing.md
@@ -16,10 +16,10 @@ var es = require('event-stream');
var File = require('vinyl');
var prefixer = require('../index');
-describe('gulp-prefixer', function () {
- describe('in streaming mode', function () {
+describe('gulp-prefixer', function() {
+ describe('in streaming mode', function() {
- it('should prepend text', function (done) {
+ it('should prepend text', function(done) {
// create the fake file
var fakeFile = new File({
@@ -33,12 +33,12 @@ describe('gulp-prefixer', function () {
myPrefixer.write(fakeFile);
// wait for the file to come back out
- myPrefixer.once('data', function (file) {
+ myPrefixer.once('data', function(file) {
// make sure it came out the same way it went in
assert(file.isStream());
// buffer the contents to make sure it got prepended to
- file.contents.pipe(es.wait(function (err, data) {
+ file.contents.pipe(es.wait(function(err, data) {
// check the contents
assert.equal(data, 'prependthistostreamwiththosecontents');
done();
@@ -59,10 +59,10 @@ var es = require('event-stream');
var File = require('vinyl');
var prefixer = require('../index');
-describe('gulp-prefixer', function () {
- describe('in buffer mode', function () {
+describe('gulp-prefixer', function() {
+ describe('in buffer mode', function() {
- it('should prepend text', function (done) {
+ it('should prepend text', function(done) {
// create the fake file
var fakeFile = new File({
@@ -76,7 +76,7 @@ describe('gulp-prefixer', function () {
myPrefixer.write(fakeFile);
// wait for the file to come back out
- myPrefixer.once('data', function (file) {
+ myPrefixer.once('data', function(file) {
// make sure it came out the same way it went in
assert(file.isBuffer());
View
4 docs/writing-a-plugin/using-buffers.md
@@ -15,7 +15,7 @@ var PluginError = gutil.PluginError;
// Consts
const PLUGIN_NAME = 'gulp-prefixer';
-// Plugin level function (dealing with files)
+// Plugin level function(dealing with files)
function gulpPrefixer(prefixText) {
if (!prefixText) {
@@ -24,7 +24,7 @@ function gulpPrefixer(prefixText) {
prefixText = new Buffer(prefixText); // allocate ahead of time
// Creating a stream through which each file will pass
- var stream = through.obj(function (file, enc, callback) {
+ var stream = through.obj(function(file, enc, callback) {
if (file.isNull()) {
this.push(file); // Do nothing if no contents
return callback();
View
4 gulpfile.js
@@ -7,14 +7,14 @@ var jshint = require('gulp-jshint');
var codeFiles = ['**/*.js', '!node_modules/**'];
-gulp.task('lint', function(){
+gulp.task('lint', function() {
log('Linting Files');
return gulp.src(codeFiles)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter());
});
-gulp.task('watch', function(){
+gulp.task('watch', function() {
log('Watching Files');
gulp.watch(codeFiles, ['lint']);
});
View
8 index.js
@@ -6,13 +6,13 @@ var gutil = require('gulp-util');
var deprecated = require('deprecated');
var vfs = require('vinyl-fs');
-function Gulp(){
+function Gulp() {
Orchestrator.call(this);
}
util.inherits(Gulp, Orchestrator);
Gulp.prototype.task = Gulp.prototype.add;
-Gulp.prototype.run = function(){
+Gulp.prototype.run = function() {
// run() is deprecated as of 3.5 and will be removed in 4.0
// use task dependencies instead
@@ -24,7 +24,7 @@ Gulp.prototype.run = function(){
Gulp.prototype.src = vfs.src;
Gulp.prototype.dest = vfs.dest;
-Gulp.prototype.watch = function (glob, opt, fn) {
+Gulp.prototype.watch = function(glob, opt, fn) {
if (!fn) {
fn = opt;
opt = null;
@@ -32,7 +32,7 @@ Gulp.prototype.watch = function (glob, opt, fn) {
// array of tasks given
if (Array.isArray(fn)) {
- return vfs.watch(glob, opt, function(){
+ return vfs.watch(glob, opt, function() {
this.start.apply(this, fn);
}.bind(this));
}
View
2  lib/taskTree.js
@@ -8,4 +8,4 @@ module.exports = function(tasks) {
});
return prev;
}, {nodes: []});
-};
+};
View
6 test/dest.js
@@ -37,7 +37,7 @@ describe('gulp output stream', function() {
String(file.contents).should.equal("this is a test");
});
outstream.on('end', function() {
- fs.readFile(join(outpath, "copy", "example.txt"), function(err, contents){
+ fs.readFile(join(outpath, "copy", "example.txt"), function(err, contents) {
should.not.exist(err);
should.exist(contents);
String(contents).should.equal("this is a test");
@@ -60,7 +60,7 @@ describe('gulp output stream', function() {
join(file.path,'').should.equal(join(outpath, "./copy/example.txt"));
});
outstream.on('end', function() {
- fs.readFile(join(outpath, "copy", "example.txt"), function(err, contents){
+ fs.readFile(join(outpath, "copy", "example.txt"), function(err, contents) {
should.exist(err);
should.not.exist(contents);
done();
@@ -81,7 +81,7 @@ describe('gulp output stream', function() {
join(file.path,'').should.equal(join(outpath, "./copy/example.txt"));
});
outstream.on('end', function() {
- fs.readFile(join(outpath, "copy", "example.txt"), function(err, contents){
+ fs.readFile(join(outpath, "copy", "example.txt"), function(err, contents) {
should.not.exist(err);
should.exist(contents);
String(contents).should.equal("this is a test");
View
4 test/src.js
@@ -116,10 +116,10 @@ describe('gulp input stream', function() {
should.exist(file.path);
should.exist(file.contents);
var buf = "";
- file.contents.on('data', function(d){
+ file.contents.on('data', function(d) {
buf += d;
});
- file.contents.on('end', function(){
+ file.contents.on('end', function() {
buf.should.equal("this is a test");
done();
});
View
2  test/taskTree.js
@@ -6,7 +6,7 @@ var should = require('should');
require('mocha');
describe('taskTree()', function() {
- it('should form a tree properly', function(done){
+ it('should form a tree properly', function(done) {
should.exist(taskTree); // lol shutup jshint
var tasks = {
View
14 test/tasks.js
@@ -60,7 +60,7 @@ describe('gulp tasks', function() {
a = 0;
fn = function() {
var deferred = Q.defer();
- setTimeout(function () {
+ setTimeout(function() {
++a;
deferred.resolve();
},1);
@@ -68,7 +68,7 @@ describe('gulp tasks', function() {
};
fn2 = function() {
var deferred = Q.defer();
- setTimeout(function () {
+ setTimeout(function() {
++a;
deferred.resolve();
},1);
@@ -77,7 +77,7 @@ describe('gulp tasks', function() {
gulp.task('test', fn);
gulp.task('test2', fn2);
gulp.run('test');
- gulp.run('test2', function () {
+ gulp.run('test2', function() {
gulp.isRunning.should.equal(false);
a.should.equal(2);
gulp.reset();
@@ -89,13 +89,13 @@ describe('gulp tasks', function() {
var a, fn, fn2;
a = 0;
fn = function(cb) {
- setTimeout(function () {
+ setTimeout(function() {
++a;
cb(null);
},1);
};
fn2 = function(cb) {
- setTimeout(function () {
+ setTimeout(function() {
++a;
cb(null);
},1);
@@ -103,7 +103,7 @@ describe('gulp tasks', function() {
gulp.task('test', fn);
gulp.task('test2', fn2);
gulp.run('test');
- gulp.run('test2', function () {
+ gulp.run('test2', function() {
gulp.isRunning.should.equal(false);
a.should.equal(2);
gulp.reset();
@@ -112,7 +112,7 @@ describe('gulp tasks', function() {
gulp.isRunning.should.equal(true);
});
it('should emit task_not_found and throw an error when task is not defined', function(done) {
- gulp.on('task_not_found', function(err){
+ gulp.on('task_not_found', function(err) {
should.exist(err);
should.exist(err.task);
err.task.should.equal('test');
View
24 test/watch.js
@@ -20,9 +20,9 @@ describe('gulp', function() {
var tempFileContent = 'A test generated this file and it is safe to delete';
var writeTimeout = 125; // Wait for it to get to the filesystem
- var writeFileWait = function (name, content, cb) {
- if (!cb) cb = function(){};
- setTimeout(function () {
+ var writeFileWait = function(name, content, cb) {
+ if (!cb) cb = function() {};
+ setTimeout(function() {
fs.writeFile(name, content, cb);
}, writeTimeout);
};
@@ -30,10 +30,10 @@ describe('gulp', function() {
// arrange
var tempFile = path.join(outpath, 'watch-func.txt');
- fs.writeFile(tempFile, tempFileContent, function () {
+ fs.writeFile(tempFile, tempFileContent, function() {
// assert: it works if it calls done
- var watcher = gulp.watch(tempFile, function (evt) {
+ var watcher = gulp.watch(tempFile, function(evt) {
should.exist(evt);
should.exist(evt.path);
should.exist(evt.type);
@@ -51,10 +51,10 @@ describe('gulp', function() {
it('should call the function when file changes: w/ options', function(done) {
// arrange
var tempFile = path.join(outpath, 'watch-func-options.txt');
- fs.writeFile(tempFile, tempFileContent, function () {
+ fs.writeFile(tempFile, tempFileContent, function() {
// assert: it works if it calls done
- var watcher = gulp.watch(tempFile, {debounceDelay:5}, function (evt) {
+ var watcher = gulp.watch(tempFile, {debounceDelay:5}, function(evt) {
should.exist(evt);
should.exist(evt.path);
should.exist(evt.type);
@@ -78,20 +78,20 @@ describe('gulp', function() {
var a = 0;
var timeout = writeTimeout * 2.5;
- fs.writeFile(tempFile, tempFileContent, function () {
+ fs.writeFile(tempFile, tempFileContent, function() {
- gulp.task(task1, function () {
+ gulp.task(task1, function() {
a++;
});
- gulp.task(task2, function () {
+ gulp.task(task2, function() {
a += 10;
});
- gulp.task(task3, function () {
+ gulp.task(task3, function() {
throw new Error("task3 called!");
});
// assert
- setTimeout(function () {
+ setTimeout(function() {
a.should.equal(11); // task1 and task2
gulp.reset();
Something went wrong with that request. Please try again.