Skip to content

Commit

Permalink
[meta] Make copy-metafiles platform-independent
Browse files Browse the repository at this point in the history
Co-authored-by: Manuel Thalmann <m@nuth.ch>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
  • Loading branch information
manuth and ljharb committed May 29, 2020
1 parent 98292ed commit 1737429
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ matrix:

before_install:
- 'nvm install-latest-npm'
- 'npm install'
- 'npm run copy-metafiles'
- 'if [ -n "${PACKAGE-}" ]; then cd "${PACKAGE}"; fi'
install:
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
"prebuild": "rimraf lib",
"build": "babel --quiet --out-dir lib src",
"postbuild": "npm run copy-metafiles",
"copy-metafiles": "for DIR in memo-parser resolvers/node resolvers/webpack utils; do cp LICENSE .npmrc \"${DIR}/\"; done",
"copy-metafiles": "node --require babel-register ./scripts/copyMetafiles",
"watch": "npm run tests-only -- -- --watch",
"pretest": "linklocal",
"posttest": "eslint .",
"mocha": "cross-env BABEL_ENV=test nyc -s mocha",
"tests-only": "npm run mocha tests/src",
"test": "npm run tests-only",
"test-compiled": "npm run prepublish && BABEL_ENV=testCompiled mocha --compilers js:babel-register tests/src",
"test-all": "npm test && for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done",
"test-all": "node --require babel-register ./scripts/testAll",
"prepublish": "not-in-publish || npm run build",
"coveralls": "nyc report --reporter lcovonly && cat ./coverage/lcov.info | coveralls"
},
Expand Down Expand Up @@ -77,9 +77,12 @@
"eslint-module-utils": "file:./utils",
"eslint-plugin-eslint-plugin": "^2.2.1",
"eslint-plugin-import": "2.x",
"fs-copy-file-sync": "^1.1.1",
"glob": "^7.1.6",
"in-publish": "^2.0.0",
"linklocal": "^2.8.2",
"mocha": "^3.5.3",
"npm-which": "^3.0.1",
"nyc": "^11.9.0",
"redux": "^3.7.2",
"rimraf": "^2.7.1",
Expand Down
22 changes: 22 additions & 0 deletions scripts/copyMetafiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import path from 'path'
import copyFileSync from 'fs-copy-file-sync'
import resolverDirectories from './resolverDirectories'

let files = [
'LICENSE',
'.npmrc',
]

let directories = [
'memo-parser',
...resolverDirectories,
'utils',
]

for (let directory of directories) {
for (let file of files) {
let destination = path.join(directory, file)
copyFileSync(file, destination)
console.log(`${file} -> ${destination}`)
}
}
3 changes: 3 additions & 0 deletions scripts/resolverDirectories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import glob from 'glob'

export default glob.sync('./resolvers/*/')
20 changes: 20 additions & 0 deletions scripts/testAll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { spawnSync } from 'child_process'
import npmWhich from 'npm-which'
import resolverDirectories from './resolverDirectories'

let npmPath = npmWhich(__dirname).sync('npm')
let spawnOptions = {
stdio: 'inherit',
}

spawnSync(
npmPath,
['test'],
Object.assign({ cwd: __dirname }, spawnOptions))

for (let resolverDir of resolverDirectories) {
spawnSync(
npmPath,
['test'],
Object.assign({ cwd: resolverDir }, spawnOptions))
}

0 comments on commit 1737429

Please sign in to comment.