Skip to content

Commit ae2c07d

Browse files
committed
Merge branch 'master' into fixopts
2 parents 631afcd + c03f2f5 commit ae2c07d

17 files changed

+295
-324
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
example/output/
2+
example/test-module/
3+
example/command-line/

.eslintrc.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
module.exports = {
2+
extends: "eslint:recommended",
3+
parserOptions: {
4+
ecmaVersion: 6,
5+
sourceType: "module",
6+
},
7+
env: {
8+
node: true,
9+
},
10+
rules: {
11+
"no-console": 0,
12+
// style
13+
"semi": 2,
14+
"no-extra-semi": 2,
15+
"no-multi-spaces": 2,
16+
"array-bracket-spacing": 2,
17+
"block-spacing": 2,
18+
"comma-spacing": 2,
19+
"comma-dangle": [2, "always-multiline"],
20+
"computed-property-spacing": 2,
21+
"eol-last": 2,
22+
"indent": [2, 2],
23+
"keyword-spacing": 2,
24+
"linebreak-style": 2,
25+
"no-spaced-func": 2,
26+
"no-trailing-spaces": 2,
27+
"object-curly-spacing": 2,
28+
"quotes": [2, "single", "avoid-escape"],
29+
"semi": 2,
30+
"semi-spacing": 2,
31+
"space-before-blocks": 2,
32+
"space-before-function-paren": [2, "never"],
33+
"space-in-parens": 2,
34+
"space-infix-ops": 2,
35+
"space-unary-ops": 2,
36+
"arrow-spacing": 2,
37+
"generator-star-spacing": 2,
38+
"template-curly-spacing": 2,
39+
"yield-star-spacing": 2,
40+
}
41+
};

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- "4.2"

CONTRIBUTING.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contributor Guidelines
2+
3+
This project has automated tests which can be run with `npm test`. This will be
4+
run in Travis CI when you make a Pull Request so please try to ensure that they
5+
are passing when submitting one. If your PR adds new features please also add
6+
tests. If your PR fixes a bug, it might be helpful to add a test which would fail
7+
if the bug was re-introduced.
8+
9+
The source code of this project is also checked for coding errors and code style
10+
consistency using ESLint. You can run it with `npm run lint` to see any errors,
11+
and you can automatically fix some coding style errors using `npm run lint-fix`.

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ $ npm install --save browserify-incremental browserify
136136

137137
to get just the library.
138138

139+
## Contributing
140+
141+
Please see the [Contributor Guidelines](CONTRIBUTING.md).
142+
139143
# license
140144

141145
MIT

bin/cmd.js

+49-49
Original file line numberDiff line numberDiff line change
@@ -2,86 +2,86 @@
22

33
var browserifyIncremental = require('../');
44
var fs = require('fs');
5-
var path = require('path');
65
var fromArgs = require('browserify/bin/args');
7-
var xtend = require('xtend');
86
var JSONStream = require('JSONStream');
97
var through = require('through2');
108

11-
process.stdout.on('error', process.exit);
9+
function run() {
10+
process.stdout.on('error', process.exit);
1211

13-
var b, outfile, verbose, cachefile;
12+
var b, outfile, verbose, cachefile;
1413

15-
var b_ = fromArgs(process.argv.slice(2), browserifyIncremental.args)
16-
cachefile = b_.argv.cachefile || './browserify-cache.json'
17-
outfile = b_.argv.o || b_.argv.outfile;
18-
verbose = (b_.argv.v || b_.argv.verbose);
19-
b = browserifyIncremental(b_, {cacheFile: cachefile});
14+
var b_ = fromArgs(process.argv.slice(2), browserifyIncremental.args);
15+
cachefile = b_.argv.cachefile || './browserify-cache.json';
16+
outfile = b_.argv.o || b_.argv.outfile;
17+
verbose = (b_.argv.v || b_.argv.verbose);
18+
b = browserifyIncremental(b_, {cacheFile: cachefile});
2019

21-
b.on('update', function(changes) {
22-
if (verbose && changes.length) console.error('changed files:\n'+changes.join('\n'));
23-
});
20+
b.on('update', function(changes) {
21+
if (verbose && changes.length) console.error('changed files:\n' + changes.join('\n'));
22+
});
2423

25-
if (b.argv.version) {
24+
if (b.argv.version) {
2625
return console.log(require('../package.json').version);
27-
}
26+
}
2827

29-
b.on('error', errorExit);
28+
b.on('error', errorExit);
3029

31-
if (b.argv.pack) {
30+
if (b.argv.pack) {
3231
process.stdin.pipe(b.pack()).pipe(process.stdout);
3332
process.stdin.resume();
3433
return;
35-
}
34+
}
3635

37-
if (b.argv.deps) {
36+
if (b.argv.deps) {
3837
var stringify = JSONStream.stringify();
3938
stringify.pipe(process.stdout);
4039
b.pipeline.get('deps').push(through.obj(
41-
function (row, enc, next) { stringify.write(row); next() },
42-
function () { stringify.end() }
40+
function(row, enc, next) { stringify.write(row); next(); },
41+
function() { stringify.end(); }
4342
));
4443
return b.bundle();
45-
}
44+
}
4645

47-
if (b.argv.list) {
48-
b.pipeline.get('deps').push(through.obj(
49-
function (row, enc, next) {
50-
console.log(row.file || row.id);
51-
next()
52-
}
53-
));
46+
if (b.argv.list) {
47+
b.pipeline.get('deps').push(through.obj(function(row, enc, next) {
48+
console.log(row.file || row.id);
49+
next();
50+
}));
5451
return b.bundle();
55-
}
52+
}
5653

57-
var bytes, time;
58-
b.on('bytes', function (b) { bytes = b });
59-
b.on('time', function (t) { time = t });
54+
var bytes, time;
55+
b.on('bytes', function(b) { bytes = b; });
56+
b.on('time', function(t) { time = t; });
6057

61-
var bundle = b.bundle();
62-
bundle.on('error', errorExit);
58+
var bundle = b.bundle();
59+
bundle.on('error', errorExit);
6360

64-
bundle.on('end', function () {
61+
bundle.on('end', function() {
6562
if (verbose) {
66-
console.error(bytes + ' bytes written to ' + (outfile || "stdout")
67-
+ ' (' + (time / 1000).toFixed(2) + ' seconds)'
68-
);
63+
console.error(bytes + ' bytes written to ' + (outfile || 'stdout')
64+
+ ' (' + (time / 1000).toFixed(2) + ' seconds)'
65+
);
6966
}
70-
});
67+
});
7168

72-
if (outfile) {
69+
if (outfile) {
7370
bundle.pipe(fs.createWriteStream(outfile));
74-
}
75-
else {
71+
}
72+
else {
7673
bundle.pipe(process.stdout);
74+
}
7775
}
7876

7977
function errorExit(err) {
80-
if (err.stack) {
81-
console.error(err.stack);
82-
}
83-
else {
84-
console.error(String(err));
85-
}
86-
process.exit(1);
78+
if (err.stack) {
79+
console.error(err.stack);
80+
}
81+
else {
82+
console.error(String(err));
83+
}
84+
process.exit(1);
8785
}
86+
87+
run();

example/build-cachefile.js

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
console.time('total')
2-
console.time('startup')
1+
console.time('total');
2+
console.time('startup');
33
var browserifyIncremental = require('../');
44
var fs = require('fs');
55

6-
console.timeEnd('startup')
7-
var counter = 10;
8-
var testTimeout = 1000;
6+
console.timeEnd('startup');
97
var cache = true;
108

11-
console.time('cache fill')
9+
console.time('cache fill');
10+
var opts;
1211
if (cache) {
13-
var opts = {cacheFile: __dirname+'/output/cache.json'}
12+
opts = {cacheFile: __dirname + '/output/cache.json'};
1413
} else {
15-
var opts = {}
14+
opts = {};
1615
}
17-
var b = browserifyIncremental(opts)
18-
console.timeEnd('cache fill')
19-
b.on('log', function(msg){ console.log(msg) })
20-
b.on('update', function(updated) { console.log('changed files\n'+updated.join('\n')) })
21-
b.add(__dirname + '/test-module')
16+
var b = browserifyIncremental(opts);
17+
console.timeEnd('cache fill');
18+
b.on('log', function(msg) { console.log(msg); });
19+
b.on('update', function(updated) { console.log('changed files\n' + updated.join('\n')); });
20+
b.add(__dirname + '/test-module');
2221

23-
process.on('exit', function () { console.timeEnd('total') })
22+
process.on('exit', function() { console.timeEnd('total'); });
2423

25-
run() // start test
24+
run(); // start test
2625

2726
function run() {
28-
console.time('bundle')
27+
console.time('bundle');
2928
b.bundle()
30-
.on('end', function(){ console.timeEnd('bundle') })
31-
.pipe(fs.createWriteStream(__dirname+'/output/bundle.js'))
29+
.on('end', function() { console.timeEnd('bundle'); })
30+
.pipe(fs.createWriteStream(__dirname + '/output/bundle.js'));
3231
}
3332

example/build-files.js

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
1-
console.time('total')
2-
console.time('startup')
1+
console.time('total');
2+
console.time('startup');
33
var browserifyIncremental = require('../');
44
var fs = require('fs');
55

6-
console.timeEnd('startup')
7-
var counter = 10;
8-
var testTimeout = 1000;
6+
console.timeEnd('startup');
97
var cache = true;
108

11-
console.time('cache fill')
9+
console.time('cache fill');
10+
var opts;
1211
if (cache) {
13-
var opts = {cacheFile: __dirname+'/output/cache.json'}
12+
opts = {cacheFile: __dirname + '/output/cache.json'};
1413
} else {
15-
var opts = {}
14+
opts = {};
1615
}
17-
var b = browserifyIncremental([__dirname + '/test-module'], opts)
18-
console.timeEnd('cache fill')
19-
b.on('log', function(msg){ console.log(msg) })
20-
b.on('update', function(updated) { console.log('changed files\n'+updated.join('\n')) })
16+
var b = browserifyIncremental([__dirname + '/test-module'], opts);
17+
console.timeEnd('cache fill');
18+
b.on('log', function(msg) { console.log(msg); });
19+
b.on('update', function(updated) { console.log('changed files\n' + updated.join('\n')); });
2120

22-
process.on('exit', function () { console.timeEnd('total') })
21+
process.on('exit', function() { console.timeEnd('total'); });
2322

24-
run() // start test
23+
run(); // start test
2524

2625
function run() {
27-
console.time('bundle')
26+
console.time('bundle');
2827
b.bundle()
29-
.on('end', function(){ console.timeEnd('bundle') })
30-
.pipe(fs.createWriteStream(__dirname+'/output/bundle.js'))
28+
.on('end', function() { console.timeEnd('bundle'); })
29+
.pipe(fs.createWriteStream(__dirname + '/output/bundle.js'));
3130
}
3231

example/build-manual-cache.js

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
1-
console.time('total')
2-
console.time('startup')
1+
console.time('total');
2+
console.time('startup');
33
var browserifyIncremental = require('../');
44
var fs = require('fs');
55

6-
console.timeEnd('startup')
7-
var counter = 10;
8-
var testTimeout = 1000;
6+
console.timeEnd('startup');
97
var cache = true;
108

11-
console.time('cache fill')
9+
console.time('cache fill');
10+
var opts;
1211
if (cache) {
13-
var incrementalCache = JSON.parse(fs.readFileSync(__dirname+'/output/cache.json', {encoding: 'utf8'}))
14-
var opts = {cache:incrementalCache.cache, mtimes: incrementalCache.mtimes}
12+
var incrementalCache = JSON.parse(fs.readFileSync(__dirname + '/output/cache.json', {encoding: 'utf8'}));
13+
opts = {cache:incrementalCache.cache, mtimes: incrementalCache.mtimes};
1514
} else {
16-
var opts = {}
15+
opts = {};
1716
}
18-
console.timeEnd('cache fill')
19-
var b = browserifyIncremental(opts)
20-
b.on('log', function(msg){ console.log(msg) })
21-
b.on('cache', function(incrementalCache) { fs.writeFile(__dirname+'/output/cache.json', JSON.stringify(incrementalCache)) })
22-
b.on('update', function(updated) { console.log('changed files', updated) })
23-
b.add(__dirname + '/test-module')
17+
console.timeEnd('cache fill');
18+
var b = browserifyIncremental(opts);
19+
b.on('log', function(msg) { console.log(msg); });
20+
b.on('cache', function(incrementalCache) { fs.writeFile(__dirname + '/output/cache.json', JSON.stringify(incrementalCache)); });
21+
b.on('update', function(updated) { console.log('changed files', updated); });
22+
b.add(__dirname + '/test-module');
2423

25-
process.on('exit', function () { console.timeEnd('total') })
24+
process.on('exit', function() { console.timeEnd('total'); });
2625

27-
run() // start test
26+
run(); // start test
2827

2928
function run() {
30-
console.time('bundle')
29+
console.time('bundle');
3130
b.bundle()
32-
.on('end', function(){ console.timeEnd('bundle') })
33-
.pipe(fs.createWriteStream(__dirname+'/output/bundle.js'))
31+
.on('end', function() { console.timeEnd('bundle'); })
32+
.pipe(fs.createWriteStream(__dirname + '/output/bundle.js'));
3433
}
3534

example/build.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ var fs = require('fs');
44
var counter = 10;
55
var testTimeout = 1000;
66

7-
var b = br()
7+
var b = br();
88
// b.on('log', function(msg){ console.log(msg) })
9-
b.add(__dirname + '/test-module')
9+
b.add(__dirname + '/test-module');
1010

11-
run() // start test
11+
run(); // start test
1212

1313
function run() {
1414
b.bundle()
1515
.on('end', next)
16-
.pipe(fs.createWriteStream(__dirname + '/output/bundle.js'))
16+
.pipe(fs.createWriteStream(__dirname + '/output/bundle.js'));
1717
}
1818

1919
function next() {
2020
if (counter-- > 0) {
21-
setTimeout(run, testTimeout)
22-
console.log('built once')
23-
} else console.log('done')
21+
setTimeout(run, testTimeout);
22+
console.log('built once');
23+
} else console.log('done');
2424
}

0 commit comments

Comments
 (0)