Skip to content

Commit 4e27b72

Browse files
updates implemeted
1 parent 542b019 commit 4e27b72

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

bootstrap/create-snapshot.js

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,33 @@ const fs = require('fs');
22
const exec_shell = require('./util/exec_script');
33

44
const main = async () => {
5-
//take snapshot name from arg
6-
const arg_input = process.argv[2];
7-
if (arg_input === undefined) {
8-
console.log('Please specify snapshot name');
9-
return;
10-
}
5+
try {
6+
//take snapshot name from arg
7+
const arg_input = process.argv[2];
8+
if (arg_input === undefined) {
9+
console.log('Please specify snapshot name');
10+
return;
11+
}
1112

12-
//check if .rnode dir exist
13-
const homedir = require('os').homedir();
14-
if (!fs.existsSync(homedir + '/.rnode')) {
15-
console.log(`Cannot snapshot: ${homedir}/.rnode does not exist`);
16-
return;
17-
}
13+
//check if .rnode dir exist
14+
const homedir = require('os').homedir();
15+
if (!fs.existsSync(homedir + '/.rnode')) {
16+
console.log(`Cannot snapshot: ${homedir}/.rnode does not exist`);
17+
return;
18+
}
1819

19-
//run stop node script
20-
require('child_process').fork('stop-rnode.js');
20+
//run stop node script
21+
require('child_process').fork('stop-rnode.js');
2122

22-
//create snapshot dir
23-
await exec_shell(`mkdir -p snapshot`);
24-
const target = `${__dirname}/snapshot/${arg_input}.tgz`;
23+
//create snapshot dir
24+
fs.mkdirSync('snapshot', { recursive: true });
25+
const target = `${__dirname}/snapshot/${arg_input}.tgz`;
2526

26-
if (fs.existsSync(target)) {
27-
console.log('snapshot already exist');
28-
return;
27+
await exec_shell(`cd ~ && tar czf "${target}" .rnode`);
28+
console.log(`snapshot created: ${target}`);
29+
} catch (error) {
30+
console.log(error);
2931
}
30-
31-
await exec_shell(`cd ~ && tar czf "${target}" .rnode`);
32-
console.log(`snapshot created: ${target}`);
3332
};
3433

3534
main();

bootstrap/stop-rnode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const main = async () => {
2424
) {
2525
await exec_shell(`kill ${formatted_string}`);
2626
} else {
27-
console.log('Aboring ...');
27+
console.log('Aborting ...');
2828
}
2929
rl.close();
3030
});

0 commit comments

Comments
 (0)