Showing the changes to node_modules/simple-git/src/util (3 of 41 files). Show all
Unified · Split
| @@ -0,0 +1,10 @@ | |||
| 1 | |||
| 2 | module.exports = function deferred () { | ||
| 3 | var d = {}; | ||
| 4 | d.promise = new Promise(function (resolve, reject) { | ||
| 5 | d.resolve = resolve; | ||
| 6 | d.reject = reject | ||
| 7 | }); | ||
| 8 | |||
| 9 | return d; | ||
| 10 | }; | ||
| @@ -0,0 +1,12 @@ | |||
| 1 | /** | ||
| 2 | * Exports the utilities `simple-git` depends upon to allow for mocking during a test | ||
| 3 | */ | ||
| 4 | module.exports = { | ||
| 5 | |||
| 6 | buffer: function () { return require('buffer').Buffer; }, | ||
| 7 | |||
| 8 | childProcess: function () { return require('child_process'); }, | ||
| 9 | |||
| 10 | exists: require('./exists') | ||
| 11 | |||
| 12 | }; | ||
| @@ -0,0 +1,33 @@ | |||
| 1 | |||
| 2 | var fs = require('fs'); | ||
| 3 | |||
| 4 | function exists (path, isFile, isDirectory) { | ||
| 5 | try { | ||
| 6 | var matches = false; | ||
| 7 | var stat = fs.statSync(path); | ||
| 8 | |||
| 9 | matches = matches || isFile && stat.isFile(); | ||
| 10 | matches = matches || isDirectory && stat.isDirectory(); | ||
| 11 | |||
| 12 | return matches; | ||
| 13 | } | ||
| 14 | catch (e) { | ||
| 15 | if (e.code === 'ENOENT') { | ||
| 16 | return false; | ||
| 17 | } | ||
| 18 | |||
| 19 | throw e; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | |||
| 23 | module.exports = function (path, type) { | ||
| 24 | if (!type) { | ||
| 25 | return exists(path, true, true); | ||
| 26 | } | ||
| 27 | |||
| 28 | return exists(path, type & 1, type & 2); | ||
| 29 | }; | ||
| 30 | |||
| 31 | module.exports.FILE = 1; | ||
| 32 | |||
| 33 | module.exports.FOLDER = 2; | ||