Skip to content

Commit

Permalink
chore: Update dependencies (#37)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Node 8 is the minimum supported version
  • Loading branch information
tleunen committed Dec 12, 2019
1 parent 18140e9 commit 4198a93
Show file tree
Hide file tree
Showing 10 changed files with 5,886 additions and 300 deletions.
7 changes: 3 additions & 4 deletions .babelrc
@@ -1,11 +1,10 @@
{
"presets": [
["env", {
["@babel/preset-env", {
"targets": {
"node": 4
"node": 8
},
"loose": true,
"useBuiltIns": true
"loose": true
}]
]
}
72 changes: 0 additions & 72 deletions .circleci/config.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,32 @@
name: Test CI

on:
pull_request:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [8.x, 10.x, 12.x, 13.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: yarn install, lint and test
run: |
yarn install
yarn run lint
yarn run test:coverage
- name: coverage
uses: codecov/codecov-action@v1.0.5
if: matrix.node-version == '13.x'
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

23 changes: 11 additions & 12 deletions package.json
Expand Up @@ -8,7 +8,7 @@
"url": "https://github.com/tleunen/find-babel-config.git"
},
"engines": {
"node": ">=4.0.0"
"node": ">=8.0.0"
},
"author": "Tommy Leunen <tommy.leunen@gmail.com> (http://tommyleunen.com)",
"license": "MIT",
Expand All @@ -20,22 +20,21 @@
"babelrc"
],
"dependencies": {
"json5": "^0.5.1",
"path-exists": "^3.0.0"
"json5": "^2.1.1",
"path-exists": "^4.0.0"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-jest": "^20.0.0",
"babel-preset-env": "^1.4.0",
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.1.3",
"eslint-plugin-import": "^2.2.0",
"jest": "^20.0.0",
"standard-version": "^4.0.0"
"@babel/cli": "^7.7.5",
"@babel/preset-env": "^7.7.6",
"babel-jest": "^24.9.0",
"eslint": "^6.7.2",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.19.1",
"jest": "^24.9.0",
"standard-version": "^7.0.1"
},
"scripts": {
"lint": "eslint src test",
"pretest": "npm run lint",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test": "jest",
Expand Down
146 changes: 73 additions & 73 deletions src/index.js
Expand Up @@ -31,84 +31,84 @@ function asyncFind(resolve, dir, depth) {

const babelrc = path.join(dir, BABELRC_FILENAME);
return pathExists(babelrc)
.then((exists) => {
if (exists) {
fs.readFile(babelrc, 'utf8', (err, data) => {
if (!err) {
resolve({
file: babelrc,
config: JSON5.parse(data),
});
}
});
}
return exists;
})
.then((exists) => {
if (!exists) {
const babelJSrc = path.join(dir, BABELRC_JS_FILENAME);
return pathExists(babelJSrc).then((ex) => {
if (ex) {
const config = getBabelJsConfig(babelJSrc);
resolve({
file: babelJSrc,
config,
});
}
});
}
return exists;
})
.then((exists) => {
if (!exists) {
const packageFile = path.join(dir, PACKAGE_FILENAME);
return pathExists(packageFile).then((ex) => {
if (ex) {
fs.readFile(packageFile, 'utf8', (err, data) => {
const packageJson = JSON.parse(data);
if (packageJson.babel) {
resolve({
file: packageFile,
config: packageJson.babel,
});
}
});
}
});
}
return exists;
})
.then((exists) => {
if (!exists) {
const babelConfigJSrc = path.join(dir, BABEL_CONFIG_JS_FILENAME);
return pathExists(babelConfigJSrc).then((ex) => {
if (ex) {
const config = getBabelJsConfig(babelConfigJSrc);
resolve({
file: babelConfigJSrc,
config,
});
.then((exists) => {
if (exists) {
fs.readFile(babelrc, 'utf8', (err, data) => {
if (!err) {
resolve({
file: babelrc,
config: JSON5.parse(data),
});
}
});
}
return exists;
})
.then((exists) => {
if (!exists) {
const babelJSrc = path.join(dir, BABELRC_JS_FILENAME);
return pathExists(babelJSrc).then((ex) => {
if (ex) {
const config = getBabelJsConfig(babelJSrc);
resolve({
file: babelJSrc,
config,
});
}
});
}
return exists;
})
.then((exists) => {
if (!exists) {
const packageFile = path.join(dir, PACKAGE_FILENAME);
return pathExists(packageFile).then((ex) => {
if (ex) {
fs.readFile(packageFile, 'utf8', (err, data) => {
const packageJson = JSON.parse(data);
if (packageJson.babel) {
resolve({
file: packageFile,
config: packageJson.babel,
});
}
});
}
});
}
return exists;
})
.then((exists) => {
if (!exists) {
const babelConfigJSrc = path.join(dir, BABEL_CONFIG_JS_FILENAME);
return pathExists(babelConfigJSrc).then((ex) => {
if (ex) {
const config = getBabelJsConfig(babelConfigJSrc);
resolve({
file: babelConfigJSrc,
config,
});
}
});
}
return exists;
})

.then((exists) => {
if (!exists) {
const nextDir = path.dirname(dir);
if (nextDir === dir) {
resolve(nullConf);
} else {
asyncFind(resolve, nextDir, depth - 1);
}
});
}
return exists;
})

.then((exists) => {
if (!exists) {
const nextDir = path.dirname(dir);
if (nextDir === dir) {
resolve(nullConf);
} else {
asyncFind(resolve, nextDir, depth - 1);
}
}
});
});
}

module.exports = function findBabelConfig(start, depth = INFINITY) {
if (!start) {
return new Promise(resolve => resolve(nullConf));
return new Promise((resolve) => resolve(nullConf));
}

const dir = path.isAbsolute(start)
Expand All @@ -131,7 +131,6 @@ module.exports.sync = function findBabelConfigSync(start, depth = INFINITY) {
: path.join(process.cwd(), start);
let loopLeft = depth;

// eslint-disable-next-line no-cond-assign
do {
const babelrc = path.join(dir, BABELRC_FILENAME);
if (pathExists.sync(babelrc)) {
Expand Down Expand Up @@ -177,6 +176,7 @@ module.exports.sync = function findBabelConfigSync(start, depth = INFINITY) {
}

loopLeft -= 1;
// eslint-disable-next-line no-cond-assign
} while (dir !== (dir = path.dirname(dir)));

return nullConf;
Expand Down
2 changes: 1 addition & 1 deletion test/data/babelrcjs/.babelrc.js
@@ -1,3 +1,3 @@
module.exports = {
"presets": ["fake-preset-babelrc"]
"presets": ["@babel/preset-env"]
}
2 changes: 1 addition & 1 deletion test/data/babelrcjs/dir1/dir2/dir3/.babelrc.js
@@ -1,3 +1,3 @@
module.exports = {
"presets": ["fake-preset-dir3-babelrc"]
"plugins": ['@babel/plugin-transform-arrow-functions']
}

0 comments on commit 4198a93

Please sign in to comment.