forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgtt-delete.js
More file actions
24 lines (19 loc) · 690 Bytes
/
gtt-delete.js
File metadata and controls
24 lines (19 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const program = require('commander');
const Frame = require('./models/frame');
const Config = require('./include/file-config');
const Cli = require('./include/cli');
const Fs = require('./include/filesystem');
program
.arguments('[id]')
.parse(process.argv);
let config = new Config(process.cwd());
let id = program.args[0];
if (
(!id || !Fs.exists(Fs.join(config.frameDir, id + '.json')))
&& -Infinity === (id = Fs.newest(config.frameDir))
)
Cli.error('No record found.');
let file = Fs.join(config.frameDir, id.replace('.json', '') + '.json');
let frame = Frame.fromFile(config, file).stopMe();
Fs.remove(file);
console.log(`Deleting record ${frame.id.magenta}`);