refactor: better testbed
This commit is contained in:
parent
d4c67d298e
commit
a899dfe659
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
||||||
node_modules
|
node_modules
|
||||||
|
package_node_modules
|
||||||
|
|
|
@ -5,11 +5,14 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
|
"glob": "7.1.4",
|
||||||
|
"mkdirp": "0.5.1",
|
||||||
"mocha": "6.0.2",
|
"mocha": "6.0.2",
|
||||||
"mochapack": "1.1.0",
|
"mochapack": "1.1.0",
|
||||||
"webpack": "4.29.6"
|
"webpack": "4.29.6"
|
||||||
},
|
},
|
||||||
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "find packages -type d -name node_modules -exec rm -r {} \\; && mochapack --watch --webpack-config webpack.test.config.js 'packages/**/*.spec.js'"
|
"test": "./sync-package-modules.sh && find packages -type d -name node_modules -exec rm -r {} \\; && mochapack --watch --webpack-config webpack.test.config.js 'packages/**/*.spec.js'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
44
sync-package-modules.sh
Executable file
44
sync-package-modules.sh
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
const child_process = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const glob = require('glob');
|
||||||
|
const mkdirp = require('mkdirp');
|
||||||
|
|
||||||
|
// Package node modules.
|
||||||
|
mkdirp.sync('package_node_modules');
|
||||||
|
const modules = [];
|
||||||
|
for (const package of glob.sync('packages/*')) {
|
||||||
|
const packageJSON = JSON.parse(
|
||||||
|
fs.readFileSync(path.join(package, 'package.json'))
|
||||||
|
);
|
||||||
|
modules.push(...Object.keys(packageJSON.dependencies || {}));
|
||||||
|
modules.push(...Object.keys(packageJSON.devDependencies || {}));
|
||||||
|
}
|
||||||
|
// Filter out packages.
|
||||||
|
const remoteModules = modules.filter((module) => {
|
||||||
|
return 0 !== module.indexOf('@avocado');
|
||||||
|
})
|
||||||
|
// Enter and run yarn.
|
||||||
|
const options = {
|
||||||
|
cwd: path.join(__dirname, 'package_node_modules'),
|
||||||
|
stdio: 'inherit',
|
||||||
|
};
|
||||||
|
child_process.spawnSync(
|
||||||
|
'yarn',
|
||||||
|
[
|
||||||
|
'init',
|
||||||
|
'-y',
|
||||||
|
],
|
||||||
|
options
|
||||||
|
);
|
||||||
|
child_process.spawnSync(
|
||||||
|
'yarn',
|
||||||
|
[
|
||||||
|
'--modules-folder',
|
||||||
|
options.cwd,
|
||||||
|
'add'
|
||||||
|
].concat(remoteModules),
|
||||||
|
options
|
||||||
|
);
|
|
@ -1,3 +1,14 @@
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@avocado': path.resolve(__dirname, 'packages'),
|
||||||
|
},
|
||||||
|
modules: [
|
||||||
|
'node_modules',
|
||||||
|
'package_node_modules',
|
||||||
|
],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user