Skip to content

Commit

Permalink
update code style, increase linter coverage, refactor makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
--global committed Jan 16, 2016
1 parent 9f5a7d0 commit f984553
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 44 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Expand Up @@ -11,3 +11,7 @@ indent_size = 4

[package.json]
indent_size = 2

[Makefile]
indent_style = tab
indent_size = 4
31 changes: 22 additions & 9 deletions Makefile
Expand Up @@ -2,14 +2,19 @@ export PATH := ./node_modules/.bin/:$(PATH):./bin/

PACKAGE = asyncjs
REQUIRE_NAME = async
NODE = node_modules/babel-cli/bin/babel-node.js
UGLIFY = node_modules/.bin/uglifyjs
XYZ = node_modules/.bin/xyz --repo git@github.com:caolan/async.git
BABEL_NODE = babel-node
UGLIFY = uglifyjs
XYZ = xyz --repo git@github.com:caolan/async.git

BUILDDIR = build
DIST = dist
SRC = lib/index.js
SCRIPTS = ./support
JS_SRC = $(shell find lib/ -type f -name '*.js') package.json
LINT_FILES = lib/ test/ mocha_test/ $(shell find perf/ -maxdepth 2 -type f) support/ gulpfile.js karma.conf.js

UMD_BUNDLE = $(BUILDDIR)/async-bundle.js
CJS_BUNDLE = $(BUILDDIR)/async-cjs.js

all: lint test clean build

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

lint:
jshint $(SRC) test/*.js mocha_test/* perf/*.js
jscs $(SRC) test/*.js mocha_test/* perf/*.js
jshint $(LINT_FILES)
jscs $(LINT_FILES)


build-bundle: build-modules $(UMD_BUNDLE) $(CJS_BUNDLE)

build-modules:
$(BABEL_NODE) $(SCRIPTS)/build/modules-cjs.js

$(UMD_BUNDLE): $(JS_SRC)
$(BABEL_NODE) $(SCRIPTS)/build/aggregate-bundle.js

$(CJS_BUNDLE): $(JS_SRC)
$(BABEL_NODE) $(SCRIPTS)/build/aggregate-cjs.js

build-bundle:
$(NODE) $(SCRIPTS)/build/modules-cjs.js
$(NODE) $(SCRIPTS)/build/aggregate-bundle.js
$(NODE) $(SCRIPTS)/build/aggregate-cjs.js
.PHONY: build-modules build-bundle

build-dist:
mkdir -p $(DIST)
Expand Down
30 changes: 15 additions & 15 deletions karma.conf.js
@@ -1,17 +1,17 @@
module.exports = function (config) {
config.set({
browsers: ['Firefox'],
files: ['mocha_test/*.js'],
frameworks: ['browserify', 'mocha'],
preprocessors: {
'**/*': ['browserify']
},
reporters: ['mocha'],
singleRun: true,
module.exports = function(config) {
config.set({
browsers: ['Firefox'],
files: ['mocha_test/*.js'],
frameworks: ['browserify', 'mocha'],
preprocessors: {
'**/*': ['browserify']
},
reporters: ['mocha'],
singleRun: true,

browserify: {
debug: true,
transform: ['babelify']
}
});
browserify: {
debug: true,
transform: ['babelify']
}
});
};
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -65,7 +65,7 @@
"scripts": {
"coverage": "nyc npm test && nyc report",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"lint": "jshint lib/*.js test/*.js perf/*.js && jscs lib/*.js test/*.js perf/*.js",
"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",
"mocha-browser-test": "karma start",
"mocha-node-test": "mocha mocha_test/ --compilers js:babel-core/register",
"mocha-test": "npm run mocha-node-test",
Expand Down
4 changes: 2 additions & 2 deletions support/build/aggregate-build.js
Expand Up @@ -5,7 +5,7 @@ import rimraf from 'rimraf/rimraf';
export default function buildBundle(options) {
function bundle() {
rollup.rollup({
entry: options.outpath + '/index.js'
entry: options.outpath + '/index.js'
}).then(function ( bundle ) {
bundle.write({
format: options.format,
Expand All @@ -15,6 +15,6 @@ export default function buildBundle(options) {
rimraf.sync(options.outpath);
}).catch(console.error);
}

compileModules(bundle, options);
}
15 changes: 12 additions & 3 deletions support/build/compile-modules.js
Expand Up @@ -9,7 +9,12 @@ import {join as joinPath} from 'path';
import fs from 'fs-extra';

export default function(cb, options) {
options = _.defaults({}, options, {path:'lib/', outpath:'build/modules', es6: false, lodashRename: false});
options = _.defaults({}, options, {
path:'lib/',
outpath:'build/modules',
es6: false,
lodashRename: false
});
let plugins = [];

if (options.lodashRename) {
Expand All @@ -24,12 +29,16 @@ export default function(cb, options) {
fs.emptyDirSync(options.outpath);
fs.emptyDirSync(joinPath(options.outpath, 'internal'));
async.each(files, (file, callback) => {
var filename = file.startsWith(options.path) ? file.slice(options.path.length) : file;
let filename = file.startsWith(options.path) ?
file.slice(options.path.length) :
file;

transformFile(file, {
babelrc: false,
plugins: plugins
}, function(err, content) {
fs.writeFile(joinPath(options.outpath, filename), content.code, callback);
let outpath = joinPath(options.outpath, filename);
fs.writeFile(outpath, content.code, callback);
});
}, cb);
});
Expand Down
4 changes: 3 additions & 1 deletion support/build/plugin-lodash-import-rename.js
Expand Up @@ -14,7 +14,9 @@ export default function() {
let dir = dirname(f).split(sep);
let relative = _.repeat('../', dir.length + 1);

node.source.value = value.replace(/\blodash\b/, relative + 'node_modules/lodash-es');
node.source.value = value.replace(
/\blodash\b/,
relative + 'node_modules/lodash-es');
}
}
}
Expand Down
28 changes: 15 additions & 13 deletions support/sync-package-managers.js
Expand Up @@ -14,36 +14,38 @@ var INCLUDES = ['lib/async.js', 'README.md', 'LICENSE'];
var REPOSITORY_NAME = 'caolan/async';

packageJson.jam = {
main: packageJson.main,
include: INCLUDES,
categories: ['Utilities']
main: packageJson.main,
include: INCLUDES,
categories: ['Utilities']
};

packageJson.spm = {
main: packageJson.main
main: packageJson.main
};

packageJson.volo = {
main: packageJson.main,
ignore: IGNORES
main: packageJson.main,
ignore: IGNORES
};

var bowerSpecific = {
moduleType: ['amd', 'globals', 'node'],
ignore: IGNORES,
authors: [packageJson.author]
moduleType: ['amd', 'globals', 'node'],
ignore: IGNORES,
authors: [packageJson.author]
};

var bowerInclude = ['name', 'description', 'main', 'keywords',
'license', 'homepage', 'repository', 'devDependencies'];
'license', 'homepage', 'repository', 'devDependencies'
];

var componentSpecific = {
repository: REPOSITORY_NAME,
scripts: [packageJson.main]
repository: REPOSITORY_NAME,
scripts: [packageJson.main]
};

var componentInclude = ['name', 'description', 'version', 'keywords',
'license', 'main'];
'license', 'main'
];

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

0 comments on commit f984553

Please sign in to comment.