Skip to content

Commit 1737429

Browse files
neurolagljharb
andcommitted
[meta] Make copy-metafiles platform-independent
Co-authored-by: Manuel Thalmann <m@nuth.ch> Co-authored-by: Jordan Harband <ljharb@gmail.com>
1 parent 98292ed commit 1737429

File tree

5 files changed

+51
-2
lines changed

5 files changed

+51
-2
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ matrix:
8989

9090
before_install:
9191
- 'nvm install-latest-npm'
92+
- 'npm install'
9293
- 'npm run copy-metafiles'
9394
- 'if [ -n "${PACKAGE-}" ]; then cd "${PACKAGE}"; fi'
9495
install:

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
"prebuild": "rimraf lib",
2222
"build": "babel --quiet --out-dir lib src",
2323
"postbuild": "npm run copy-metafiles",
24-
"copy-metafiles": "for DIR in memo-parser resolvers/node resolvers/webpack utils; do cp LICENSE .npmrc \"${DIR}/\"; done",
24+
"copy-metafiles": "node --require babel-register ./scripts/copyMetafiles",
2525
"watch": "npm run tests-only -- -- --watch",
2626
"pretest": "linklocal",
2727
"posttest": "eslint .",
2828
"mocha": "cross-env BABEL_ENV=test nyc -s mocha",
2929
"tests-only": "npm run mocha tests/src",
3030
"test": "npm run tests-only",
3131
"test-compiled": "npm run prepublish && BABEL_ENV=testCompiled mocha --compilers js:babel-register tests/src",
32-
"test-all": "npm test && for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done",
32+
"test-all": "node --require babel-register ./scripts/testAll",
3333
"prepublish": "not-in-publish || npm run build",
3434
"coveralls": "nyc report --reporter lcovonly && cat ./coverage/lcov.info | coveralls"
3535
},
@@ -77,9 +77,12 @@
7777
"eslint-module-utils": "file:./utils",
7878
"eslint-plugin-eslint-plugin": "^2.2.1",
7979
"eslint-plugin-import": "2.x",
80+
"fs-copy-file-sync": "^1.1.1",
81+
"glob": "^7.1.6",
8082
"in-publish": "^2.0.0",
8183
"linklocal": "^2.8.2",
8284
"mocha": "^3.5.3",
85+
"npm-which": "^3.0.1",
8386
"nyc": "^11.9.0",
8487
"redux": "^3.7.2",
8588
"rimraf": "^2.7.1",

scripts/copyMetafiles.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import path from 'path'
2+
import copyFileSync from 'fs-copy-file-sync'
3+
import resolverDirectories from './resolverDirectories'
4+
5+
let files = [
6+
'LICENSE',
7+
'.npmrc',
8+
]
9+
10+
let directories = [
11+
'memo-parser',
12+
...resolverDirectories,
13+
'utils',
14+
]
15+
16+
for (let directory of directories) {
17+
for (let file of files) {
18+
let destination = path.join(directory, file)
19+
copyFileSync(file, destination)
20+
console.log(`${file} -> ${destination}`)
21+
}
22+
}

scripts/resolverDirectories.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import glob from 'glob'
2+
3+
export default glob.sync('./resolvers/*/')

scripts/testAll.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { spawnSync } from 'child_process'
2+
import npmWhich from 'npm-which'
3+
import resolverDirectories from './resolverDirectories'
4+
5+
let npmPath = npmWhich(__dirname).sync('npm')
6+
let spawnOptions = {
7+
stdio: 'inherit',
8+
}
9+
10+
spawnSync(
11+
npmPath,
12+
['test'],
13+
Object.assign({ cwd: __dirname }, spawnOptions))
14+
15+
for (let resolverDir of resolverDirectories) {
16+
spawnSync(
17+
npmPath,
18+
['test'],
19+
Object.assign({ cwd: resolverDir }, spawnOptions))
20+
}

0 commit comments

Comments
 (0)