Start multiple projects using 1 command(npm start).
|
1 year ago | |
---|---|---|
projects | 1 year ago | |
.gitignore | 1 year ago | |
README.md | 1 year ago | |
general-stuff.js | 1 year ago | |
index.js | 1 year ago | |
package-lock.json | 1 year ago | |
package.json | 1 year ago |
This project will start multiple other projects in the same terminal, with different colors. And watch on all the projects for changes.
npm install
start
function from general-stuff.jsstart
functionDeclare an apps array, each object has to have those fields.
{
option: number, // mandatory, hex or binary converted to decimal (1, 2, 4, 8, 16, ...)
name: string, // mandatory, name of the project
enable: boolean, // mandatory, check if the project has to run
color: string, // mandatory, color to display in terminal for this project
custom: string, // mandatory if startFile is not provided, custom script to run, instead of nodemon to watch the current project
startFile: string, // mandatory if custom is not provided, location to the start file of the project
options: any, // optional, is used only when startFile is used, this is used to passed to project as argument
otherfields: any, // optional, you can declare other fields to use in your commands
}
There is a COLORS
enum inside the general-stuff.js
file.
const { COLORS } = require('./general-stuff');
// Those colors can be used.
COLORS.black
COLORS.red
COLORS.green
COLORS.yellow
COLORS.blue
COLORS.magenta
COLORS.cyan
COLORS.white
COLORS.gray
COLORS.close
Declare your common commands to run on all projects(with startFile property provided)
{{propertyName}}
&&
eg.
[
'echo "hello world"', // first command
'cd ~/projects/{{name}}' // cd to the project folder of the current project in the list, name property is used here, but you can also declare your own properties
]
const { start } = require('./general-stuff')
...
start(apps, command);
yargs package is also installed as a dependency, you can use that for example to enable or disable from the command line and pass it to the start
function as the third parameter. For an example, you can see the index.js
file.
const { argv } = require('yargs');
const value = parseInt(argv.option, 10);
...
start(apps, command, value);