Skip to content

Commit

Permalink
build: replace nodemon with chokidar
Browse files Browse the repository at this point in the history
  • Loading branch information
siguse committed Mar 3, 2021
1 parent e2e88b3 commit 3b7854b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
32 changes: 21 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
const { ensureValidPath, fileName } = require('./scripts/filename');
const nodemon = require('nodemon');
const chokidar = require('chokidar');
const child_process = require('child_process');

const path = ensureValidPath(fileName(process.argv[2]));

nodemon(`-I --quiet --config nodemon.json ${path}`);
let sandbox;

nodemon.on('start', () => {
function startSandbox() {
console.clear();
console.log('started', new Date().toISOString());
}).on('quit', () => {
//
}).on('restart', (files) => {
console.clear();
console.log('restarted', new Date().toISOString(), files);
}).once('exit', () => {
process.exit(0);
console.log(new Date(), "sandbox starting");
sandbox = child_process.spawn('ts-node', [path], {
stdio: 'inherit'
});
sandbox.on('exit', (exitCode) => {
if (exitCode === 130) {
console.log(new Date(), "sandbox aborting");
process.exit(0);
}
});
}

chokidar.watch(path).on('change', () => {
sandbox.kill();
startSandbox();
});

startSandbox();
12 changes: 0 additions & 12 deletions nodemon.json

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/erhise/offline-blitz#readme",
"dependencies": {
"nodemon": "^2.0.7",
"chokidar": "^3.5.1",
"rxjs": "^6.6.3",
"ts-node": "^9.1.1",
"typescript": "^4.2.2"
Expand Down
7 changes: 3 additions & 4 deletions scripts/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function buildUi(data = {}) {
},
columnSpacing: 1,
});

// Create exeuction triggered log
executionLog = grid.set(15, 0, 21, 4, contrib.log, {
label: 'Execution triggered',
Expand All @@ -68,7 +68,7 @@ function buildUi(data = {}) {
selectedBg: 'blue',
padding: { left: 1, right: 1 },
});

actions = data.actions !== undefined ? data.actions : DEFAULT_DATA.actions;
actionList.setItems(actions.map(action => action.title));

Expand All @@ -80,7 +80,6 @@ function buildUi(data = {}) {
selectedFg: 'green',
});


// focus list directly
actionList.focus();
screen.render();
Expand All @@ -90,7 +89,7 @@ function buildMenuCommands(extras = {}) {
let defaultCmds = {
' Exit': {
keys: ['Q-q', 'Q', 'q', 'C-c', 'escape'],
callback: () => process.exit(0),
callback: () => process.exit(130),
},
' Action': {
keys: ['n', 'enter'],
Expand Down

0 comments on commit 3b7854b

Please sign in to comment.