Skip to content

Commit f984553

Browse files
author
--global
committed
update code style, increase linter coverage, refactor makefile
1 parent 9f5a7d0 commit f984553

8 files changed

+74
-44
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ indent_size = 4
1111

1212
[package.json]
1313
indent_size = 2
14+
15+
[Makefile]
16+
indent_style = tab
17+
indent_size = 4

Makefile

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ export PATH := ./node_modules/.bin/:$(PATH):./bin/
22

33
PACKAGE = asyncjs
44
REQUIRE_NAME = async
5-
NODE = node_modules/babel-cli/bin/babel-node.js
6-
UGLIFY = node_modules/.bin/uglifyjs
7-
XYZ = node_modules/.bin/xyz --repo [email protected]:caolan/async.git
5+
BABEL_NODE = babel-node
6+
UGLIFY = uglifyjs
7+
XYZ = xyz --repo [email protected]:caolan/async.git
88

99
BUILDDIR = build
1010
DIST = dist
1111
SRC = lib/index.js
1212
SCRIPTS = ./support
13+
JS_SRC = $(shell find lib/ -type f -name '*.js') package.json
14+
LINT_FILES = lib/ test/ mocha_test/ $(shell find perf/ -maxdepth 2 -type f) support/ gulpfile.js karma.conf.js
15+
16+
UMD_BUNDLE = $(BUILDDIR)/async-bundle.js
17+
CJS_BUNDLE = $(BUILDDIR)/async-cjs.js
1318

1419
all: lint test clean build
1520

@@ -21,14 +26,22 @@ clean:
2126
rm -rf $(DIST)
2227

2328
lint:
24-
jshint $(SRC) test/*.js mocha_test/* perf/*.js
25-
jscs $(SRC) test/*.js mocha_test/* perf/*.js
29+
jshint $(LINT_FILES)
30+
jscs $(LINT_FILES)
31+
32+
33+
build-bundle: build-modules $(UMD_BUNDLE) $(CJS_BUNDLE)
34+
35+
build-modules:
36+
$(BABEL_NODE) $(SCRIPTS)/build/modules-cjs.js
37+
38+
$(UMD_BUNDLE): $(JS_SRC)
39+
$(BABEL_NODE) $(SCRIPTS)/build/aggregate-bundle.js
2640

41+
$(CJS_BUNDLE): $(JS_SRC)
42+
$(BABEL_NODE) $(SCRIPTS)/build/aggregate-cjs.js
2743

28-
build-bundle:
29-
$(NODE) $(SCRIPTS)/build/modules-cjs.js
30-
$(NODE) $(SCRIPTS)/build/aggregate-bundle.js
31-
$(NODE) $(SCRIPTS)/build/aggregate-cjs.js
44+
.PHONY: build-modules build-bundle
3245

3346
build-dist:
3447
mkdir -p $(DIST)

karma.conf.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
module.exports = function (config) {
2-
config.set({
3-
browsers: ['Firefox'],
4-
files: ['mocha_test/*.js'],
5-
frameworks: ['browserify', 'mocha'],
6-
preprocessors: {
7-
'**/*': ['browserify']
8-
},
9-
reporters: ['mocha'],
10-
singleRun: true,
1+
module.exports = function(config) {
2+
config.set({
3+
browsers: ['Firefox'],
4+
files: ['mocha_test/*.js'],
5+
frameworks: ['browserify', 'mocha'],
6+
preprocessors: {
7+
'**/*': ['browserify']
8+
},
9+
reporters: ['mocha'],
10+
singleRun: true,
1111

12-
browserify: {
13-
debug: true,
14-
transform: ['babelify']
15-
}
16-
});
12+
browserify: {
13+
debug: true,
14+
transform: ['babelify']
15+
}
16+
});
1717
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"scripts": {
6666
"coverage": "nyc npm test && nyc report",
6767
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
68-
"lint": "jshint lib/*.js test/*.js perf/*.js && jscs lib/*.js test/*.js perf/*.js",
68+
"lint": "jshint lib/ test/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/ gulpfile.js karma.conf.js && jscs lib/ test/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/ gulpfile.js karma.conf.js",
6969
"mocha-browser-test": "karma start",
7070
"mocha-node-test": "mocha mocha_test/ --compilers js:babel-core/register",
7171
"mocha-test": "npm run mocha-node-test",

support/build/aggregate-build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import rimraf from 'rimraf/rimraf';
55
export default function buildBundle(options) {
66
function bundle() {
77
rollup.rollup({
8-
entry: options.outpath + '/index.js'
8+
entry: options.outpath + '/index.js'
99
}).then(function ( bundle ) {
1010
bundle.write({
1111
format: options.format,
@@ -15,6 +15,6 @@ export default function buildBundle(options) {
1515
rimraf.sync(options.outpath);
1616
}).catch(console.error);
1717
}
18-
18+
1919
compileModules(bundle, options);
2020
}

support/build/compile-modules.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import {join as joinPath} from 'path';
99
import fs from 'fs-extra';
1010

1111
export default function(cb, options) {
12-
options = _.defaults({}, options, {path:'lib/', outpath:'build/modules', es6: false, lodashRename: false});
12+
options = _.defaults({}, options, {
13+
path:'lib/',
14+
outpath:'build/modules',
15+
es6: false,
16+
lodashRename: false
17+
});
1318
let plugins = [];
1419

1520
if (options.lodashRename) {
@@ -24,12 +29,16 @@ export default function(cb, options) {
2429
fs.emptyDirSync(options.outpath);
2530
fs.emptyDirSync(joinPath(options.outpath, 'internal'));
2631
async.each(files, (file, callback) => {
27-
var filename = file.startsWith(options.path) ? file.slice(options.path.length) : file;
32+
let filename = file.startsWith(options.path) ?
33+
file.slice(options.path.length) :
34+
file;
35+
2836
transformFile(file, {
2937
babelrc: false,
3038
plugins: plugins
3139
}, function(err, content) {
32-
fs.writeFile(joinPath(options.outpath, filename), content.code, callback);
40+
let outpath = joinPath(options.outpath, filename);
41+
fs.writeFile(outpath, content.code, callback);
3342
});
3443
}, cb);
3544
});

support/build/plugin-lodash-import-rename.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export default function() {
1414
let dir = dirname(f).split(sep);
1515
let relative = _.repeat('../', dir.length + 1);
1616

17-
node.source.value = value.replace(/\blodash\b/, relative + 'node_modules/lodash-es');
17+
node.source.value = value.replace(
18+
/\blodash\b/,
19+
relative + 'node_modules/lodash-es');
1820
}
1921
}
2022
}

support/sync-package-managers.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,38 @@ var INCLUDES = ['lib/async.js', 'README.md', 'LICENSE'];
1414
var REPOSITORY_NAME = 'caolan/async';
1515

1616
packageJson.jam = {
17-
main: packageJson.main,
18-
include: INCLUDES,
19-
categories: ['Utilities']
17+
main: packageJson.main,
18+
include: INCLUDES,
19+
categories: ['Utilities']
2020
};
2121

2222
packageJson.spm = {
23-
main: packageJson.main
23+
main: packageJson.main
2424
};
2525

2626
packageJson.volo = {
27-
main: packageJson.main,
28-
ignore: IGNORES
27+
main: packageJson.main,
28+
ignore: IGNORES
2929
};
3030

3131
var bowerSpecific = {
32-
moduleType: ['amd', 'globals', 'node'],
33-
ignore: IGNORES,
34-
authors: [packageJson.author]
32+
moduleType: ['amd', 'globals', 'node'],
33+
ignore: IGNORES,
34+
authors: [packageJson.author]
3535
};
3636

3737
var bowerInclude = ['name', 'description', 'main', 'keywords',
38-
'license', 'homepage', 'repository', 'devDependencies'];
38+
'license', 'homepage', 'repository', 'devDependencies'
39+
];
3940

4041
var componentSpecific = {
41-
repository: REPOSITORY_NAME,
42-
scripts: [packageJson.main]
42+
repository: REPOSITORY_NAME,
43+
scripts: [packageJson.main]
4344
};
4445

4546
var componentInclude = ['name', 'description', 'version', 'keywords',
46-
'license', 'main'];
47+
'license', 'main'
48+
];
4749

4850
var bowerJson = _.merge({}, _.pick(packageJson, bowerInclude), bowerSpecific);
4951
var componentJson = _.merge({}, _.pick(packageJson, componentInclude), componentSpecific);

0 commit comments

Comments
 (0)