forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilesystem.js
More file actions
executable file
·41 lines (33 loc) · 912 Bytes
/
filesystem.js
File metadata and controls
executable file
·41 lines (33 loc) · 912 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const _ = require('underscore');
const fs = require('fs');
const path = require('path');
const open = require('open');
const find = require('find-in-files');
class filesystem {
static find(pattern, dir) {
return new Promise((resolve, reject) => {
find.find(pattern, dir)
.then(results => resolve(_.keys(results)))
.catch(error => reject(error));
});
}
static exists(file) {
return fs.existsSync(file);
}
static remove(file) {
return fs.unlinkSync(file);
}
static open(file) {
return open(file);
}
static join(...args) {
return path.join(...args);
}
static newest(dir) {
return _.max(fs.readdirSync(dir), file => (fs.statSync(path.join(dir, file)).ctime));
}
static readDir(dir) {
return fs.readdirSync(dir);
}
}
module.exports = filesystem;