Criando npm scripts
entendendo o problema...
// package.json
...
"scripts": {
"clean": "rm -rf ./build",
"build": "npm run clean && tsc",
"lint": "eslint src/**/*.ts",
"deploy": "./deploy.sh"
},
...
#
ou pelo menos a mesma versão dele...
import { glob } from 'glob'
// all js files, but don't look in node_modules
const jsfiles = await glob('**/*.js', {
ignore: 'node_modules/**'
});
// pass in a signal to cancel the glob walk
const stopAfter100ms = await glob('**/*.css', {
signal: AbortSignal.timeout(100),
});
#
// package.json
...
"scripts": {
"clean": "rm -rf ./build",
"build": "npm run clean && tsc",
"lint": "eslint src/**/*.ts ",
"deploy": "./deploy.sh"
},
...
#
// package.json
...
"scripts": {
"clean": "rm -rf ./build",
"build": "npm run clean && tsc",
"lint": "eslint 'src/**/*.ts'",
"deploy": "./deploy.sh"
},
...
$ shx mkdir -p foo
$ shx touch foo/bar.txt
$ shx rm -rf foo
#
var shell = require('shelljs');
if (!shell.which('git')) {
shell.echo('Sorry, this script requires git');
shell.exit(1);
}
// Copy files to release dir
shell.rm('-rf', 'out/Release');
shell.cp('-R', 'stuff/', 'out/Release');
// Replace macros in each .js file
shell.cd('lib');
shell.ls('*.js').forEach(file => {
shell.sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
shell.sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, shell.cat('macro.js'), file);
});
shell.cd('..');
// Run external tool synchronously
if (shell.exec('git commit -am "Auto-commit"').code !== 0) {
shell.echo('Error: Git commit failed');
shell.exit(1);
}
# PRESENTING CODE
// package.json
...
"scripts": {
"clean": "shx rm -rf ./build",
"build": "npm run clean && tsc",
"lint": "eslint 'src/**/*.ts'",
"deploy": "node ./deploy.js"
},
...
#
$ npm-run-all clean lint build
$ npm-run-all clean lint --parallel watch:html watch:js
$ npm-run-all --parallel 'watch:**'
# shortcuts
$ run-s 'build:**'
$ run-p 'build:**'
#
"scripts": {
"start": "run-s build 'start-server -- --port {1}' --"
}
$ npm start 8080
#
// package.json
...
"scripts": {
"clean": "shx rm -rf ./build",
"ts-build": "tsc ./tsconfig.json",
"build": "npm-run-all clean ts-build",
"lint": "eslint 'src/**/*.ts'",
"deploy": "node ./deploy.js"
},
...
#
// package.json
...
"scripts": {
"build:1:clean": "shx rm -rf ./build",
"build:2:ts": "tsc ./tsconfig.json",
"build": "nun-s 'build:**'",
"lint": "eslint 'src/**/*.ts'",
"deploy": "node ./deploy.js"
},
...
#