package.json scripts: use NodeJS instead of unix commands
This commit is contained in:
parent
4cbc73a25f
commit
60e32042f7
@ -86,6 +86,7 @@
|
||||
},
|
||||
"ignorePatterns": [
|
||||
"jest.config.js",
|
||||
"scripts/**/*",
|
||||
"dist/**/*",
|
||||
"config/**/*"
|
||||
],
|
||||
|
10
package.json
10
package.json
@ -14,12 +14,12 @@
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "jest --verbose --runInBand",
|
||||
"clean": "(test ! -d dist || rm -r dist)",
|
||||
"prepareSources": "cp package.json src/",
|
||||
"clean": "node scripts/clean.js",
|
||||
"prepare-sources": "node scripts/prepare-sources.js",
|
||||
"compile": "yarn clean && tsc",
|
||||
"build": "yarn prepareSources && yarn compile && cp -r yarn.lock README.md config/ views/ dist/ && mkdir dist/types && cp src/types/* dist/types/",
|
||||
"dev": "yarn prepareSources && concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon\" \"maildev\"",
|
||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
||||
"build": "yarn prepare-sources && yarn compile && node scripts/dist.js",
|
||||
"dev": "yarn prepare-sources && concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon\" \"maildev\"",
|
||||
"lint": "eslint .",
|
||||
"release": "yarn build && yarn lint && yarn test && cd dist && yarn publish"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
10
scripts/clean.js
Normal file
10
scripts/clean.js
Normal file
@ -0,0 +1,10 @@
|
||||
const fs = require('fs');
|
||||
|
||||
[
|
||||
'dist',
|
||||
].forEach(file => {
|
||||
if (fs.existsSync(file)) {
|
||||
console.log('Cleaning', file, '...');
|
||||
fs.rmSync(file, {recursive: true});
|
||||
}
|
||||
});
|
34
scripts/dist.js
Normal file
34
scripts/dist.js
Normal file
@ -0,0 +1,34 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function copyRecursively(file, destination) {
|
||||
const target = path.join(destination, path.basename(file));
|
||||
if (fs.statSync(file).isDirectory()) {
|
||||
console.log('mkdir', target);
|
||||
|
||||
fs.mkdirSync(target, {recursive: true});
|
||||
fs.readdirSync(file).forEach(f => {
|
||||
copyRecursively(path.join(file, f), target);
|
||||
});
|
||||
} else {
|
||||
console.log('> cp ', target);
|
||||
|
||||
fs.copyFileSync(file, target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[
|
||||
'yarn.lock',
|
||||
'README.md',
|
||||
'config/',
|
||||
'views/',
|
||||
].forEach(file => {
|
||||
copyRecursively(file, 'dist');
|
||||
});
|
||||
|
||||
fs.mkdirSync('dist/types', {recursive: true});
|
||||
|
||||
fs.readdirSync('src/types').forEach(file => {
|
||||
copyRecursively(path.join('src/types', file), 'dist/types');
|
||||
});
|
4
scripts/prepare-sources.js
Normal file
4
scripts/prepare-sources.js
Normal file
@ -0,0 +1,4 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
fs.copyFileSync('package.json', path.join('src', 'package.json'));
|
Loading…
Reference in New Issue
Block a user