Small task runner for node.js
Create Pinefile
or pinefile.js
const { pkg, run } = require('@pinefile/pine');
exports.build = () => {
console.log(`Building ${pkg().version}...`);
}
exports.test = async () => {
await run('jest');
}
or by using module.exports
module.exports = {
build: () => {
console.log(`Building ${pkg().version}...`);
},
test: async () => {
await run('jest');
},
};
pkg
function will read closest package.json
Then run it! It is best to either place pine
inside a npm run script or run it with npx
:
npx pine build
You can split up tasks in more than one file, e.g having all build tasks in one file:
// tasks/build.js
module.exports = {
css: () => console.log('build:css'),
default: () => console.log('build'),
};
// pinefile.js
module.exports = {
build: require('./tasks/build.js'),
};
Then you can run npx pine build:css
Example of how to use Babel transpiler for your pinefile.js
{
"pine": {
"requires": ["@babel/register"]
},
"babel": {
"presets": ["env"]
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/register": "^7.12.1"
}
}
Example of how to use TypeScript transpiler for your pinefile.js
{
"pine": {
"requires": ["ts-node/register"]
},
"devDependencies": {
"ts-node": "^9.0.0",
"typescript": "^4.0.5"
}
}
MIT © Fredrik Forsmo