Projekt

Obecné

Profil

Stáhnout (845 Bajtů) Statistiky
| Větev: | Revize:
1
/*
2
	MIT License http://www.opensource.org/licenses/mit-license.php
3
	Author Tobias Koppers @sokra
4
*/
5
"use strict";
6

    
7
const fs = require("graceful-fs");
8

    
9
class NodeJsInputFileSystem {
10
	readdir(path, callback) {
11
		fs.readdir(path, (err, files) => {
12
			callback(err, files && files.map(file => {
13
				return file.normalize ? file.normalize("NFC") : file;
14
			}));
15
		});
16
	}
17

    
18
	readdirSync(path) {
19
		const files = fs.readdirSync(path);
20
		return files && files.map(file => {
21
			return file.normalize ? file.normalize("NFC") : file;
22
		});
23
	}
24
}
25

    
26
const fsMethods = [
27
	"stat",
28
	"statSync",
29
	"readFile",
30
	"readFileSync",
31
	"readlink",
32
	"readlinkSync"
33
];
34

    
35
for(const key of fsMethods) {
36
	Object.defineProperty(NodeJsInputFileSystem.prototype, key, {
37
		configurable: true,
38
		writable: true,
39
		value: fs[key].bind(fs)
40
	});
41
}
42

    
43
module.exports = NodeJsInputFileSystem;
(20-20/37)