Skip to content

Commit

Permalink
chore: Upgrade deps (tleunen#37)
Browse files Browse the repository at this point in the history
* chore: Upgrade deps

* revert babel-plugin-module-resolver peerDep

* Fix use strict in test suite
  • Loading branch information
tleunen authored Feb 5, 2017
1 parent c526927 commit e775e16
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 185 deletions.
6 changes: 0 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,4 @@ end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4

[*.{json,yml}]
indent_size = 2

[.*]
indent_size = 2
5 changes: 1 addition & 4 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
root: true

extends:
- "tleunen"

parserOptions:
sourceType: 'script'
- "airbnb-base"
9 changes: 4 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
machine:
post:
- curl -o- -L https://yarnpkg.com/install.sh | bash
environment:
PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
dependencies:
cache_directories:
- "~/.npm"
- "~/.yarn-cache"
- ~/.cache/yarn
pre:
- case $CIRCLE_NODE_INDEX in 0) NODE_VERSION=4 ;; 1) NODE_VERSION=6 ;; 2) NODE_VERSION=7 ;; esac; nvm install $NODE_VERSION && nvm alias default $NODE_VERSION
override:
- yarn --no-lockfile
test:
override:
- npm t
- yarn test
deployment:
coverage:
branch: /.*/
Expand Down
23 changes: 15 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
"resolve": "^1.2.0"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-cli": "^6.22.2",
"babel-core": "^6.22.1",
"babel-jest": "^18.0.0",
"babel-plugin-module-resolver": "^2.4.0",
"babel-plugin-transform-object-rest-spread": "^6.20.2",
"eslint": "^3.12.2",
"eslint-config-tleunen": "^1.0.0",
"babel-plugin-module-resolver": "^2.5.0",
"babel-plugin-transform-object-rest-spread": "^6.22.0",
"eslint": "^3.15.0",
"eslint-config-airbnb-base": "^11.0.1",
"eslint-plugin-import": "^2.2.0",
"jest": "^18.0.0",
"lodash": "^4.17.2",
"jest": "^18.1.0",
"lodash": "^4.17.4",
"standard-version": "^4.0.0"
},
"peerDependencies": {
Expand All @@ -64,5 +64,12 @@
"collectCoverageFrom": [
"src/**/*.js"
]
},
"greenkeeper": {
"ignore": [
"babel-jest",
"eslint",
"eslint-plugin-import"
]
}
}
74 changes: 36 additions & 38 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const path = require('path');
const resolve = require('resolve');
const pkgUp = require('pkg-up');
Expand All @@ -8,35 +6,35 @@ const mapModule = require('babel-plugin-module-resolver').mapModule;
const OptionManager = require('babel-core').OptionManager;

function getPlugins(file, target) {
try {
const manager = new OptionManager();
const result = manager.init({
babelrc: true,
filename: file,
});
try {
const manager = new OptionManager();
const result = manager.init({
babelrc: true,
filename: file,
});

return result.plugins.filter((plugin) => {
const plug = OptionManager.memoisedPlugins.find(item =>
return result.plugins.filter((plugin) => {
const plug = OptionManager.memoisedPlugins.find(item =>
item.plugin === plugin[0],
);

return plug && plug.container === target;
});
} catch (err) {
return plug && plug.container === target;
});
} catch (err) {
// This error should only occur if something goes wrong with babel's
// internals. Dump it to console so people know what's going on,
// elsewise the error will simply be squelched in the calling code.
console.error('[eslint-import-resolver-babel-module]', err);
console.error('See: https://github.com/tleunen/eslint-import-resolver-babel-module/pull/34');
return [];
}
console.error('[eslint-import-resolver-babel-module]', err);
console.error('See: https://github.com/tleunen/eslint-import-resolver-babel-module/pull/34');
return [];
}
}

function opts(file, config) {
return {
...config,
basedir: path.dirname(file),
};
return {
...config,
basedir: path.dirname(file),
};
}

exports.interfaceVersion = 2;
Expand All @@ -51,25 +49,25 @@ exports.interfaceVersion = 2;
* @return {object}
*/
exports.resolve = (source, file, options) => {
if (resolve.isCore(source)) return { found: true, path: null };
if (resolve.isCore(source)) return { found: true, path: null };

const projectRootDir = path.dirname(pkgUp.sync(file));
const projectRootDir = path.dirname(pkgUp.sync(file));

try {
const instances = getPlugins(file, targetPlugin);
try {
const instances = getPlugins(file, targetPlugin);

const pluginOpts = instances.reduce((config, plugin) => ({
cwd: plugin[1] && plugin[1].cwd ? plugin[1].cwd : config.cwd,
root: config.root.concat(plugin[1] && plugin[1].root ? plugin[1].root : []),
alias: Object.assign(config.alias, plugin[1] ? plugin[1].alias : {}),
}), { root: [], alias: {}, cwd: projectRootDir });
const pluginOpts = instances.reduce((config, plugin) => ({
cwd: plugin[1] && plugin[1].cwd ? plugin[1].cwd : config.cwd,
root: config.root.concat(plugin[1] && plugin[1].root ? plugin[1].root : []),
alias: Object.assign(config.alias, plugin[1] ? plugin[1].alias : {}),
}), { root: [], alias: {}, cwd: projectRootDir });

const src = mapModule(source, file, pluginOpts, path.resolve(pluginOpts.cwd)) || source;
return {
found: true,
path: resolve.sync(src, opts(file, options)),
};
} catch (e) {
return { found: false };
}
const src = mapModule(source, file, pluginOpts, path.resolve(pluginOpts.cwd)) || source;
return {
found: true,
path: resolve.sync(src, opts(file, options)),
};
} catch (e) {
return { found: false };
}
};
Loading

0 comments on commit e775e16

Please sign in to comment.