@m-c2/install
v1.0.0
Published
A script to deploy and run a configuration for a project
Downloads
1
Readme
Mc2-runner
This package helps to quickly configure the behavior of cli command. For simple usage where you do not have watch & run logic, you can use this package.
Usage
If you already have a config file
npx @m-c2/runner
If you do not have a default config file, you can create it by running
npx @m-c2/runner --init
This will create the default template for you to edit, named mc2-runner.config.js
Config file
// mc2-runner.config.js
// Available colors
// red, green, yellow, blue, magenta, cyan,
// brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan,
// black , white , gray
// or custom color if supported by your terminal : #XXXXXX as hex color
module.exports = [
{
// Name to display for this process (Ex: Typescript Compiler)
name: '',
// Command to run (Ex: yarn tsc)
command: '',
// If present, the process will restart when a file matching the pattern changes
watch: {
pattern: '', // Ex : Watching path like src/**/*.ts
},
// If true, the process will start automatically when the runner is started
// If false, but a watch is configured, the process will start when a file change
autoStart: false,
// Color of the process in the console
color: 'blue',
// Color of the process in the console when a file change
fileChangeColor: 'green',
// When watch is active, define if the process restart or not on file change
restartOnWatchChange: true,
// When watch is active, Execute the method
// This method can be async or not
// can return void or an array of string representing a name of one of the process to start / restart
triggerMethod: null,
}
];
For exemple, if you have a small command to run when a file change, or a server to restart, you can use this package to do it. you can do it this way
// mc2-runner.config.js
module.exports = [
{
name : 'TypeScript Compiler',
command : 'yarn tsc',
watch : {
pattern: 'src/**/*.ts', // Watch all TypeScript files in the src directory and its subdirectories
},
color : 'blue',
fileChangeColor : 'green',
restartOnWatchChange : true,
triggerMethod : null, // No trigger method specified for this process
},
{
name : 'Node App',
command : 'node dist/App-Runner.js',
watch : {
pattern: 'out/App.js', // Watch the app.js file in the dist/js directory
},
restartOnWatchChange: true,
// Function can be async or not
triggerMethod: () => {
// Copy new files to target directory
// ... logic here
},
},
];