-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatch.js
More file actions
executable file
·45 lines (42 loc) · 1.3 KB
/
Copy pathwatch.js
File metadata and controls
executable file
·45 lines (42 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env node
const { exec } = require("child_process");
const log4js = require("log4js");
const fs = require('fs');
log4js.configure({
appenders: {
"stdout" : { type: "stdout" },
"file" : { type: "file", filename: "logs/watch.log" }
},
categories: {
default: { appenders: [ 'stdout', 'file' ], level: 'info' }
}
});
const logger = log4js.getLogger();
require('esbuild').build({
entryPoints: ['src/index.js'],
outfile: 'dist/index.js',
sourcemap: true,
bundle: true,
platform: 'node',
watch: {
onRebuild(error, result) {
if (error) console.error('watch build failed:', error)
else {
console.log('About to restart docker instance');
exec("docker restart lambda", (error, stdout, stderr) => {
if (error) {
logger.error(`error: ${error.message}`);
return;
}
if (stderr) {
logger.error(`stderr: ${stderr}`);
return;
}
logger.info(`stdout: ${stdout}`);
});
}
},
},
}).then(result => {
console.log('watching...')
})