Skip to content
This repository was archived by the owner on Sep 10, 2019. It is now read-only.

Commit c4914ef

Browse files
committed
fix: only cleanup if req + show help on no command
1 parent 850443c commit c4914ef

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

bin/dev.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ export const handler = async ({
105105
};
106106

107107
cleanup((exitCode, signal) => {
108-
log(' -> cleaning up temporary files');
109108
// Delete the temporary directory.
110-
cleanUpTempDir().then(() => {
111-
success('Successfully shut down. Thanks for using GrAMPS!');
109+
cleanUpTempDir().then(shouldPrintShutdownMessage => {
110+
if (shouldPrintShutdownMessage) {
111+
success('Successfully shut down. Thanks for using GrAMPS!');
112+
}
113+
112114
process.kill(process.pid, signal);
113115
});
114116

bin/gramps.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import dev from './dev';
44

55
yargs
66
.command(dev)
7-
// .demandCommand()
7+
.demandCommand()
88
.help().argv;

lib/data-sources.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ const getDirName = dir =>
3131
.slice(-1)
3232
.pop();
3333

34-
export const cleanUpTempDir = () => del(TEMP_DIR, { force: true });
34+
export const cleanUpTempDir = () => {
35+
if (fs.existsSync(TEMP_DIR)) {
36+
log(' -> cleaning up temporary files');
37+
return del(TEMP_DIR, { force: true });
38+
}
39+
40+
// If there’s no temp dir, return a resolved promise (basically a no-op).
41+
return Promise.resolve(false);
42+
};
3543

3644
const makeTempDir = tmpDir =>
3745
new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)