recently-modified-files 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -11
- package/CHANGELOG.md +0 -14
- package/dist/index.js +0 -60
package/package.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "recently-modified-files",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Gets the most recent modified file on a dir",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author":
|
|
7
|
-
"name": "Mauricio Poppe",
|
|
8
|
-
"email": "mauricio.poppe@gmail.com",
|
|
9
|
-
"url": "http://maurizzzio.com"
|
|
10
|
-
},
|
|
6
|
+
"author": "Mauricio Poppe (https://mauriciopoppe.com)",
|
|
11
7
|
"main": "dist/index.js",
|
|
12
8
|
"jsnext:main": "src/index.js",
|
|
13
9
|
"keywords": [
|
|
@@ -15,14 +11,10 @@
|
|
|
15
11
|
"file",
|
|
16
12
|
"recently modified"
|
|
17
13
|
],
|
|
18
|
-
"repository": "
|
|
14
|
+
"repository": "mauriciopoppe/recently-modified-files",
|
|
19
15
|
"scripts": {
|
|
20
|
-
"clean": "rimraf dist/ && mkdirp dist/",
|
|
21
|
-
"lint": "standard",
|
|
22
|
-
"prebuild": "npm run clean -s && npm run lint -s",
|
|
23
16
|
"build": "babel src/index.js --out-file dist/index.js",
|
|
24
17
|
"build:watch": "npm run build -- --watch",
|
|
25
|
-
"preversion": "npm run build",
|
|
26
18
|
"test": "ava",
|
|
27
19
|
"test:watch": "npm test -- --watch",
|
|
28
20
|
"coverage": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov"
|
package/CHANGELOG.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
All notable changes to this project will be documented in this file.
|
|
3
|
-
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
|
-
|
|
5
|
-
## [0.1.1] - 2016-05-14
|
|
6
|
-
|
|
7
|
-
### Features
|
|
8
|
-
|
|
9
|
-
- Added a promisified version `mrf.promise`
|
|
10
|
-
|
|
11
|
-
## [0.1.0] - 2016-05-14
|
|
12
|
-
|
|
13
|
-
Initial release
|
|
14
|
-
|
package/dist/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = asynch;
|
|
7
|
-
exports.sync = sync;
|
|
8
|
-
exports.promise = promise;
|
|
9
|
-
|
|
10
|
-
var _fs = require('fs');
|
|
11
|
-
|
|
12
|
-
var _fs2 = _interopRequireDefault(_fs);
|
|
13
|
-
|
|
14
|
-
var _path = require('path');
|
|
15
|
-
|
|
16
|
-
var _path2 = _interopRequireDefault(_path);
|
|
17
|
-
|
|
18
|
-
var _folderStat = require('folder-stat');
|
|
19
|
-
|
|
20
|
-
var _folderStat2 = _interopRequireDefault(_folderStat);
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
|
-
function fmr(stats, files) {
|
|
25
|
-
var onlyFiles = stats.map(function (stat, i) {
|
|
26
|
-
stat.filename = files[i];
|
|
27
|
-
return stat;
|
|
28
|
-
}).filter(function (stat) {
|
|
29
|
-
return stat.isFile();
|
|
30
|
-
});
|
|
31
|
-
onlyFiles.sort(function (a, b) {
|
|
32
|
-
return b.mtime - a.mtime;
|
|
33
|
-
});
|
|
34
|
-
return onlyFiles.map(function (stat) {
|
|
35
|
-
return stat.filename;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function asynch(dir, cb) {
|
|
40
|
-
(0, _folderStat2.default)(dir, function (err, stats, files) {
|
|
41
|
-
if (err) return cb(err);
|
|
42
|
-
return cb(null, fmr(stats, files));
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function sync(dir) {
|
|
47
|
-
var files = _fs2.default.readdirSync(dir);
|
|
48
|
-
var stats = files.map(function (file) {
|
|
49
|
-
return _fs2.default.statSync(_path2.default.join(dir, file));
|
|
50
|
-
});
|
|
51
|
-
return fmr(stats, files);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function promise(dir) {
|
|
55
|
-
return new Promise(function (resolve, reject) {
|
|
56
|
-
asynch(dir, function (err, files) {
|
|
57
|
-
if (err) reject(err);else resolve(files);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
}
|