package.json scripts: use NodeJS instead of unix commands
This commit is contained in:
parent
f7fa3ca67f
commit
2bcf37f811
@ -89,6 +89,7 @@ module.exports = {
|
|||||||
ignorePatterns: [
|
ignorePatterns: [
|
||||||
'.eslintrc.js',
|
'.eslintrc.js',
|
||||||
'jest.config.js',
|
'jest.config.js',
|
||||||
|
'scripts/**/*',
|
||||||
'dist/**/*',
|
'dist/**/*',
|
||||||
'config/**/*',
|
'config/**/*',
|
||||||
'public/**/*'
|
'public/**/*'
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest --verbose --runInBand",
|
"test": "jest --verbose --runInBand",
|
||||||
"clean": "(test ! -d dist || rm -r dist)",
|
"clean": "node scripts/clean.js",
|
||||||
"prepareSources": "cp package.json src/",
|
"prepareSources": "node scripts/prepareSources.js",
|
||||||
"compile": "yarn clean && tsc",
|
"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/",
|
"build": "yarn prepareSources && yarn compile && node scripts/dist.js",
|
||||||
"dev": "yarn prepareSources && concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon -i public\" \"maildev\"",
|
"dev": "yarn prepareSources && concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon -i public\" \"maildev\"",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"release": "yarn build && yarn lint && yarn test && cd dist && yarn publish"
|
"release": "yarn build && yarn lint && yarn test && cd dist && yarn publish"
|
||||||
|
12
scripts/clean.js
Normal file
12
scripts/clean.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
[
|
||||||
|
'build',
|
||||||
|
'dist',
|
||||||
|
'public',
|
||||||
|
].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/prepareSources.js
Normal file
4
scripts/prepareSources.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