Skip to content

Commit

Permalink
pref: use yarn,airbnb-base/fix automatically code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
59naga committed Jul 3, 2018
1 parent d422095 commit 73be7a6
Show file tree
Hide file tree
Showing 8 changed files with 5,394 additions and 64 deletions.
8 changes: 6 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
extends: airbnb/base
extends:
- airbnb-base
parser: babel-eslint

env:
Expand All @@ -15,4 +16,7 @@ rules:
max-len: 1
arrow-body-style: 1

global-require: 0
global-require: 1
import/no-extraneous-dependencies: 1
import/no-dynamic-require: 1
prefer-destructuring: 1
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ env:
language: node_js
node_js:
- 0
- 4
- 5
before_install:
- if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
before_script:
- npm prune
- 6
- 10
script:
- npm run cover
- npm run build
Expand All @@ -42,4 +38,4 @@ deploy:
api_key:
secure: fup0t0KFvc2ht2/uWUQ1CdWBtSKOeQYJc3ipN9OxO1z+6HhuAd1ZoXdgb+lX9K2AkSq+F8uVinRyZeZfyDYdhzRG0Y4j2yWjDQNTha+JCChmU2+0nYwKWSB0/AOlBISVy8wCXAuq0RiVuFTNlK9wKxj2IuHjb9WebBq8dJEQLpc=
on:
node: 4
node: 6
39 changes: 20 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,33 @@
"abigail-plugin-log": "^0.3.0",
"abigail-plugin-parse": "^0.7.0",
"abigail-plugin-watch": "^0.2.0",
"source-map-support": "^0.4.0"
"source-map-support": "^0.5.6"
},
"devDependencies": {
"babel-cli": "^6.6.5",
"babel-eslint": "^6.0.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.5",
"babel-plugin-transform-object-assign": "^6.5.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2015-rollup": "^1.1.1",
"babel-preset-power-assert": "^1.0.0",
"babel-preset-stage-1": "^6.5.0",
"babel-register": "^6.7.2",
"carrack": "0.3",
"babel-preset-power-assert": "^2.0.0",
"babel-preset-stage-1": "^6.24.1",
"babel-register": "^6.26.0",
"carrack": "0.5",
"chopsticks": "^0.6.0",
"climb-lookup": "^1.0.0",
"codeclimate-test-reporter": "^0.3.1",
"conventional-github-releaser": "^1.1.1",
"cross-env": "^1.0.7",
"codeclimate-test-reporter": "^0.5.0",
"conventional-github-releaser": "^3.1.2",
"cross-env": "^5.2.0",
"deep-assign": "^2.0.0",
"eslint": "^2.6.0",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.8.0",
"mocha": "^2.4.5",
"npm-run-all": "^2.1.1",
"eslint": "^5.0.1",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-plugin-import": "^2.13.0",
"mocha": "^5.2.0",
"npm-run-all": "^4.1.3",
"npm-statement": "^0.0.0",
"nyc": "^6.1.1",
"nyc": "^12.0.2",
"pascal-case": "^2.0.0",
"power-assert": "^1.3.1",
"rollup": "0.26.3",
Expand All @@ -61,7 +62,7 @@
"rollup-plugin-json": "2.0.0",
"rollup-plugin-node-resolve": "1.5.0",
"rollup-plugin-uglify": "0.3.1",
"sinon": "^1.17.3"
"sinon": "^6.0.1"
},
"repository": {
"type": "git",
Expand Down
10 changes: 7 additions & 3 deletions src/Abigail.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export default class Abigail extends AsyncEmitter {
* @returns {abigail} this - the self instance
*/
initialize(argv, options = { process }) {
const { _, sentence, dash: scriptSuffixes, ...cliOptions } = chopsticks(argv, {
const {
_, sentence, dash: scriptSuffixes, ...cliOptions
} = chopsticks(argv, {
sentence: true,
nest: true,
dash: true,
Expand Down Expand Up @@ -63,10 +65,12 @@ export default class Abigail extends AsyncEmitter {
const plugins = utils.loadPlugins(this, pluginOptions);

// ['a','b','c'] -> [['a'],['b'],['c']]
const parallel = _.map((task) => [task]);
const parallel = _.map(task => [task]);

const sentenceWithLowdash = _.length ? sentence.concat(parallel) : sentence;
this.props = { sentence: sentenceWithLowdash, json, scriptSuffixes, opts, pluginOptions, plugins };
this.props = {
sentence: sentenceWithLowdash, json, scriptSuffixes, opts, pluginOptions, plugins,
};

return this;
}
Expand Down
40 changes: 20 additions & 20 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ import Abigail from './Abigail';
export default (argv, options = {}) => {
const abigail = new Abigail(options).initialize(argv);
abigail.emit('initialized')
.then(() => abigail.emit('parse'))
.then(() => abigail.emit('attach-plugins'))
.then(() => abigail.emit('launch'))
.then(() => {
if (abigail.listeners('exit').length) {
return abigail.emit('detach-plugins')
.then(() => abigail.emit('exit'));
}
.then(() => abigail.emit('parse'))
.then(() => abigail.emit('attach-plugins'))
.then(() => abigail.emit('launch'))
.then(() => {
if (abigail.listeners('exit').length) {
return abigail.emit('detach-plugins')
.then(() => abigail.emit('exit'));
}

return process.once('SIGINT', () => {
try {
abigail.props.plugins.log.abort();
} catch (e) {
return process.once('SIGINT', () => {
try {
abigail.props.plugins.log.abort();
} catch (e) {
// ignore
}
}

abigail.emit('detach-plugins')
.then(() => abigail.emit('exit'));
abigail.emit('detach-plugins')
.then(() => abigail.emit('exit'));
});
})
.catch((reason) => {
console.trace(reason.message); // eslint-disable-line no-console
process.exit(1);
});
})
.catch((reason) => {
console.trace(reason.message); // eslint-disable-line no-console
process.exit(1);
});
};
18 changes: 11 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ export function lookupJson(cwd) {
const data = { scripts: {} };
const options = {};

return { path, dir, data, options };
return {
path, dir, data, options,
};
}

const dir = dirname(path);
const data = JSON.parse(readFileSync(path));
const options = data.abigail || {};

return { path, dir, data, options };
return {
path, dir, data, options,
};
}

/**
Expand All @@ -36,8 +40,8 @@ export function lookupJson(cwd) {
export function resolvePluginOptions(args = {}, options = { enableIfObject: false }) {
const pluginOptions = {};

Object.keys(args).forEach(key => {
if (args.hasOwnProperty(key) === false) {
Object.keys(args).forEach((key) => {
if (Object.prototype.hasOwnProperty.call(args, key) === false) {
return;
}
if (args[key] === null || args[key] === undefined) {
Expand Down Expand Up @@ -76,7 +80,7 @@ export function resolvePlugin(name, constructor) {
if (typeof constructor === 'function') {
return constructor;
}
if (name.match(/^[\w\-]+$/) === null) {
if (name.match(/^[\w-]+$/) === null) {
return require(resolvePaths(process.cwd(), name));
}
if (name.match(/^abigail-plugin/)) {
Expand All @@ -94,8 +98,8 @@ export function resolvePlugin(name, constructor) {
export function loadPlugins(parent, options = {}) {
const plugins = {};

Object.keys(options).forEach(name => {
if (options.hasOwnProperty(name) === false) {
Object.keys(options).forEach((name) => {
if (Object.prototype.hasOwnProperty.call(options, name) === false) {
return;
}

Expand Down
12 changes: 6 additions & 6 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,28 @@ describe('utils', () => {

describe('.resolvePlugin', () => {
it('in long name, it should return the constructor', () => {
const emitter = new AsyncEmitter;
const emitter = new AsyncEmitter();
const Plugin = utils.resolvePlugin('abigail-plugin-parse');
const plugin = new Plugin(emitter);
assert(plugin.name === 'parse');
});

it('in short name, it should return the constructor', () => {
const emitter = new AsyncEmitter;
const emitter = new AsyncEmitter();
const Plugin = utils.resolvePlugin('parse');
const plugin = new Plugin(emitter);
assert(plugin.name === 'parse');
});

it('if specify a path, should be require and returnes', () => {
const emitter = new AsyncEmitter;
const emitter = new AsyncEmitter();
const Plugin = utils.resolvePlugin(require.resolve('abigail-plugin-parse'));
const plugin = new Plugin(emitter);
assert(plugin.name === 'parse');
});

it('if specify a constructor to the second argument, it should be returned as it is', () => {
const emitter = new AsyncEmitter;
const emitter = new AsyncEmitter();
const Plugin = utils.resolvePlugin(null, require('abigail-plugin-parse'));
const plugin = new Plugin(emitter);
assert(plugin.name === 'parse');
Expand All @@ -102,14 +102,14 @@ describe('utils', () => {

describe('.loadPlugins', () => {
it('if specify pluginOpts.enable is true, should be a plugin enable', () => {
const emitter = new AsyncEmitter;
const emitter = new AsyncEmitter();
const plugins = utils.loadPlugins(emitter, { parse: { enable: true } });

assert(plugins.parse.parent === emitter);
});

it('if specify pluginOpts.enable is false, should be a plugin disable', () => {
const emitter = new AsyncEmitter;
const emitter = new AsyncEmitter();
const plugins = utils.loadPlugins(emitter, { parse: { enable: false } });

assert(plugins.parse === undefined);
Expand Down
Loading

0 comments on commit 73be7a6

Please sign in to comment.