1.0.20 • Published 7 years ago
scripts-helper v1.0.20
scripts-helper
This is a package manager scripts helper. It can add global package and use current package manager to do it.
Support:
- npm
- yarn
Not support yet:
- pnpm (because I can't make a distinction between npm and pnpm in run-script)
Note
This module don't support preinstall hook.
- Because before install this module, you can't require / import this module.
You can use typescript to write the script code, but it is not recommand.
- If you execute
tsc
in script, it will complie .ts to .js and maybe cause some errors.
Compare with npx:
- npx not support global package execute binary
- if you don't install local package, npx will install each running
- use this module to save disk space and speed running or use npx to get no side effects
Install
- npm:
npm install scripts-helper
- yarn:
yarn add scripts-helper
Example
If you create a build script, run like:
- npm:
npm run build
- yarn:
yarn run build
package.json
{
"scripts": {
"build": "node ./.scripts/build.js"
}
}
build.js
'use strict';
const script = () => {
const {PackageManagerFactory, shell} = require('scripts-helper');
const manager = PackageManagerFactory.instance.detectManager();
const packages = ['webpack', 'webpack-cli', {name: 'ts-loader', link: true}];
if (false === manager.requireGlobalPackage('typescript')) {
process.exit(1);
}
if (false === manager.requireAllGlobalPackages(packages)) {
process.exit(1);
}
if (false === shell('tsc')) {
process.exit(1);
}
if (false === shell('webpack')) {
process.exit(1);
}
};
script();
1.0.20
7 years ago
1.0.19
7 years ago
1.0.18
7 years ago
1.0.17
7 years ago
1.0.16
7 years ago
1.0.15
7 years ago
1.0.14
7 years ago
1.0.13
7 years ago
1.0.12
7 years ago
1.0.11
7 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago