initial commit
This commit is contained in:
20
node_modules/fs-plus/LICENSE.md
generated
vendored
Normal file
20
node_modules/fs-plus/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2013 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
235
node_modules/fs-plus/README.md
generated
vendored
Normal file
235
node_modules/fs-plus/README.md
generated
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
# fs plus
|
||||
[](https://travis-ci.org/atom/fs-plus)
|
||||
[](https://ci.appveyor.com/project/Atom/fs-plus/branch/master)
|
||||
[](https://david-dm.org/atom/fs-plus)
|
||||
|
||||
Yet another filesystem helper based on node's [fs](http://nodejs.org/api/fs.html)
|
||||
module. This library exports everything from node's fs module but with some
|
||||
extra helpers.
|
||||
|
||||
## Using
|
||||
|
||||
```sh
|
||||
npm install fs-plus
|
||||
```
|
||||
|
||||
```coffee
|
||||
fs = require 'fs-plus'
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
### `getHomeDirectory()`
|
||||
Returns the absolute path to the home directory.
|
||||
|
||||
### `absolute(relativePath)`
|
||||
Make the given path absolute by resolving it against the current
|
||||
working directory.
|
||||
|
||||
### Params
|
||||
|
||||
- **String** `relativePath`: The string representing the relative path. If the
|
||||
path is prefixed with '~', it will be expanded to the current user's home
|
||||
directory.
|
||||
|
||||
### Return
|
||||
|
||||
- **String**: The absolute path or the relative path if it's unable to
|
||||
determine its real path.
|
||||
|
||||
### `normalize(pathToNormalize)`
|
||||
Normalize the given path treating a leading `~` segment as referring to the
|
||||
home directory. This method does not query the filesystem.
|
||||
|
||||
#### Params
|
||||
|
||||
- **String** `pathToNormalize`: The string containing the abnormal path. If the
|
||||
path is prefixed with '~', it will be expanded to the current user's home
|
||||
directory.
|
||||
|
||||
#### Return
|
||||
- **String** Returns a normalized path.
|
||||
|
||||
### `tildify(pathToTildify)`
|
||||
Convert an absolute path to tilde path for linux and mac:
|
||||
/Users/username/dev => ~/dev
|
||||
|
||||
#### Params
|
||||
|
||||
- **String** `pathToTildify`: The string containing the full path.
|
||||
|
||||
#### Return
|
||||
- **String** Returns a tildified path.
|
||||
|
||||
### `getAppDataDirectory()`
|
||||
Get path to store application specific data.
|
||||
|
||||
#### Return
|
||||
- **String** Returns the absolute path or null if platform isn't supported
|
||||
|
||||
- Mac: `~/Library/Application Support/`
|
||||
- Win: `%AppData%`
|
||||
- Linux: `/var/lib`
|
||||
|
||||
### `isAbsolute(pathToCheck)`
|
||||
Is the given path absolute?
|
||||
|
||||
#### Params
|
||||
- **String** `pathToCheck`: The relative or absolute path to check.
|
||||
|
||||
#### Return
|
||||
- **Bolean** Returns `true` if the path is absolute, `false` otherwise.
|
||||
|
||||
### `existsSync(pathToCheck)`
|
||||
Returns `true` if a file or folder at the specified path exists.
|
||||
|
||||
### `isDirectorySync(directoryPath)`
|
||||
Returns `true` if the given path exists and is a directory.
|
||||
|
||||
### `isDirectory(directoryPath)`
|
||||
Asynchronously checks that the given path exists and is a directory.
|
||||
|
||||
### `isFileSync(filePath)`
|
||||
Returns true if the specified path exists and is a file.
|
||||
|
||||
### `isSymbolicLinkSync(symlinkPath)`
|
||||
Returns `true` if the specified path is a symbolic link.
|
||||
|
||||
### `isSymbolicLink(symlinkPath, callback)`
|
||||
Calls back with `true` if the specified path is a symbolic link.
|
||||
|
||||
### `isExecutableSync(pathToCheck)`
|
||||
Returns `true` if the specified path is executable.
|
||||
|
||||
### `getSizeSync(pathToCheck)`
|
||||
Returns the size of the specified path.
|
||||
|
||||
### `listSync(rootPath, extensions)`
|
||||
Returns an Array with the paths of the files and directories
|
||||
contained within the directory path. It is not recursive.
|
||||
|
||||
## Params
|
||||
- **String** `rootPath`: The absolute path to the directory to list.
|
||||
- **Array** `extensions`: An array of extensions to filter the results by. If none are
|
||||
given, none are filtered (optional).
|
||||
|
||||
### `list(rootPath, extensions)`
|
||||
Asynchronously lists the files and directories in the given path. The listing is not recursive.
|
||||
|
||||
### `listTreeSync(rootPath)`
|
||||
Get all paths under the given path.
|
||||
|
||||
#### Params
|
||||
- **String** `rootPath` The {String} path to start at.
|
||||
|
||||
#### Return
|
||||
- **Array** Returns an array of strings under the given path.
|
||||
|
||||
### `moveSync(source, target)`
|
||||
Moves the file or directory to the target synchronously.
|
||||
|
||||
### `removeSync(pathToRemove)`
|
||||
Removes the file or directory at the given path synchronously.
|
||||
|
||||
### `writeFileSync(filePath, content, options)`
|
||||
Open, write, flush, and close a file, writing the given content synchronously.
|
||||
It also creates the necessary parent directories.
|
||||
|
||||
### `writeFile(filePath, content, options, callback)`
|
||||
Open, write, flush, and close a file, writing the given content
|
||||
asynchronously.
|
||||
It also creates the necessary parent directories.
|
||||
|
||||
### `copySync(sourcePath, destinationPath)`
|
||||
Copies the given path recursively and synchronously.
|
||||
|
||||
### `makeTreeSync(directoryPath)`
|
||||
Create a directory at the specified path including any missing
|
||||
parent directories synchronously.
|
||||
|
||||
### `makeTree(directoryPath, callback)`
|
||||
Create a directory at the specified path including any missing
|
||||
parent directories asynchronously.
|
||||
|
||||
### `traverseTreeSync(rootPath, onFile, onDirectory)`
|
||||
Recursively walk the given path and execute the given functions
|
||||
synchronously.
|
||||
|
||||
#### Params
|
||||
- **String** `rootPath`: The string containing the directory to recurse into.
|
||||
- **Function** `onFile`: The function to execute on each file, receives a single argument
|
||||
the absolute path.
|
||||
- **Function** `onDirectory`: The function to execute on each directory, receives a single
|
||||
argument the absolute path (defaults to onFile). If this
|
||||
function returns a falsy value then the directory is not
|
||||
entered.
|
||||
|
||||
### `traverseTree(rootPath, onFile, onDirectory, onDone)`
|
||||
Public: Recursively walk the given path and execute the given functions
|
||||
asynchronously.
|
||||
|
||||
### `md5ForPath(pathToDigest)`
|
||||
Hashes the contents of the given file.
|
||||
|
||||
#### Params
|
||||
- **String** `pathToDigest`: The string containing the absolute path.
|
||||
|
||||
#### Return
|
||||
- **String** Returns a string containing the MD5 hexadecimal hash.
|
||||
|
||||
### `resolve(loadPaths, pathToResolve, extensions)`
|
||||
Finds a relative path among the given array of paths.
|
||||
|
||||
#### Params
|
||||
- **Array** `loadPaths`: An array of absolute and relative paths to search.
|
||||
- **String** `pathToResolve` The string containing the path to resolve.
|
||||
- **Array** `extensions` An array of extensions to pass to {resolveExtensions} in
|
||||
which case pathToResolve should not contain an extension
|
||||
(optional).
|
||||
|
||||
#### Return
|
||||
Returns the absolute path of the file to be resolved if it's found and
|
||||
undefined otherwise.
|
||||
|
||||
### `resolveOnLoadPath()`
|
||||
Like `.resolve` but uses node's modules paths as the load paths to
|
||||
search.
|
||||
|
||||
### `resolveExtension(pathToResolve, extensions)`
|
||||
Finds the first file in the given path which matches the extension
|
||||
in the order given.
|
||||
|
||||
#### Params
|
||||
- **String** `pathToResolve`: the string containing relative or absolute path of the
|
||||
file in question without the extension or '.'.
|
||||
- **Array** `extensions`: the ordered array of extensions to try.
|
||||
|
||||
#### Return
|
||||
Returns the absolute path of the file if it exists with any of the given
|
||||
extensions, otherwise it's undefined.
|
||||
|
||||
### `isCompressedExtension(ext)`
|
||||
Returns true for extensions associated with compressed files.
|
||||
|
||||
### `isImageExtension(ext)`
|
||||
Returns true for extensions associated with image files.
|
||||
|
||||
### `isPdfExtension(ext)`
|
||||
Returns true for extensions associated with pdf files.
|
||||
|
||||
### `isBinaryExtension(ext)`
|
||||
Returns true for extensions associated with binary files.
|
||||
|
||||
### `isReadmePath(readmePath)`
|
||||
Returns true for files named similarily to 'README'
|
||||
|
||||
### `isMarkdownExtension(ext)`
|
||||
Returns true for extensions associated with Markdown files.
|
||||
|
||||
### `isCaseInsensitive()`
|
||||
Is the filesystem case insensitive?
|
||||
Returns `true` if case insensitive, `false` otherwise.
|
||||
|
||||
### `isCaseSensitive()`
|
||||
Is the filesystem case sensitive?
|
||||
Returns `true` if case sensitive, `false` otherwise.
|
||||
17
node_modules/fs-plus/appveyor.yml
generated
vendored
Normal file
17
node_modules/fs-plus/appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
environment:
|
||||
nodejs_version: "6"
|
||||
|
||||
platform:
|
||||
- x64
|
||||
- x86
|
||||
|
||||
install:
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
- npm install
|
||||
|
||||
test_script:
|
||||
- node -e "console.log(`${process.version} ${process.arch} ${process.platform}`)"
|
||||
- npm --version
|
||||
- npm test
|
||||
|
||||
build: off
|
||||
699
node_modules/fs-plus/lib/fs-plus.js
generated
vendored
Normal file
699
node_modules/fs-plus/lib/fs-plus.js
generated
vendored
Normal file
@@ -0,0 +1,699 @@
|
||||
(function() {
|
||||
var BINARY_EXTENSIONS, COMPRESSED_EXTENSIONS, IMAGE_EXTENSIONS, MARKDOWN_EXTENSIONS, Module, async, fs, fsPlus, isMoveTargetValid, isMoveTargetValidSync, isPathValid, lstatSyncNoException, mkdirp, path, rimraf, statSyncNoException, _,
|
||||
__slice = [].slice;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
Module = require('module');
|
||||
|
||||
path = require('path');
|
||||
|
||||
_ = require('underscore-plus');
|
||||
|
||||
async = require('async');
|
||||
|
||||
mkdirp = require('mkdirp');
|
||||
|
||||
rimraf = require('rimraf');
|
||||
|
||||
fsPlus = {
|
||||
getHomeDirectory: function() {
|
||||
if (process.platform === 'win32') {
|
||||
return process.env.USERPROFILE;
|
||||
} else {
|
||||
return process.env.HOME;
|
||||
}
|
||||
},
|
||||
absolute: function(relativePath) {
|
||||
var e;
|
||||
if (relativePath == null) {
|
||||
return null;
|
||||
}
|
||||
relativePath = fsPlus.resolveHome(relativePath);
|
||||
try {
|
||||
return fs.realpathSync(relativePath);
|
||||
} catch (_error) {
|
||||
e = _error;
|
||||
return relativePath;
|
||||
}
|
||||
},
|
||||
normalize: function(pathToNormalize) {
|
||||
if (pathToNormalize == null) {
|
||||
return null;
|
||||
}
|
||||
return fsPlus.resolveHome(path.normalize(pathToNormalize.toString()));
|
||||
},
|
||||
resolveHome: function(relativePath) {
|
||||
if (relativePath === '~') {
|
||||
return fsPlus.getHomeDirectory();
|
||||
} else if (relativePath.indexOf("~" + path.sep) === 0) {
|
||||
return "" + (fsPlus.getHomeDirectory()) + (relativePath.substring(1));
|
||||
}
|
||||
return relativePath;
|
||||
},
|
||||
tildify: function(pathToTildify) {
|
||||
var homeDir, normalized;
|
||||
if (process.platform === 'win32') {
|
||||
return pathToTildify;
|
||||
}
|
||||
normalized = fsPlus.normalize(pathToTildify);
|
||||
homeDir = fsPlus.getHomeDirectory();
|
||||
if (normalized === homeDir) {
|
||||
return '~';
|
||||
}
|
||||
if (!normalized.startsWith(path.join(homeDir, path.sep))) {
|
||||
return pathToTildify;
|
||||
}
|
||||
return path.join('~', path.sep, normalized.substring(homeDir.length + 1));
|
||||
},
|
||||
getAppDataDirectory: function() {
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return fsPlus.absolute(path.join('~', 'Library', 'Application Support'));
|
||||
case 'linux':
|
||||
return '/var/lib';
|
||||
case 'win32':
|
||||
return process.env.APPDATA;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
isAbsolute: function(pathToCheck) {
|
||||
if (pathToCheck == null) {
|
||||
pathToCheck = '';
|
||||
}
|
||||
if (process.platform === 'win32') {
|
||||
if (pathToCheck[1] === ':') {
|
||||
return true;
|
||||
}
|
||||
if (pathToCheck[0] === '\\' && pathToCheck[1] === '\\') {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return pathToCheck[0] === '/';
|
||||
}
|
||||
return false;
|
||||
},
|
||||
existsSync: function(pathToCheck) {
|
||||
return isPathValid(pathToCheck) && (statSyncNoException(pathToCheck) !== false);
|
||||
},
|
||||
isDirectorySync: function(directoryPath) {
|
||||
var stat;
|
||||
if (!isPathValid(directoryPath)) {
|
||||
return false;
|
||||
}
|
||||
if (stat = statSyncNoException(directoryPath)) {
|
||||
return stat.isDirectory();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
isDirectory: function(directoryPath, done) {
|
||||
if (!isPathValid(directoryPath)) {
|
||||
return done(false);
|
||||
}
|
||||
return fs.stat(directoryPath, function(error, stat) {
|
||||
if (error != null) {
|
||||
return done(false);
|
||||
} else {
|
||||
return done(stat.isDirectory());
|
||||
}
|
||||
});
|
||||
},
|
||||
isFileSync: function(filePath) {
|
||||
var stat;
|
||||
if (!isPathValid(filePath)) {
|
||||
return false;
|
||||
}
|
||||
if (stat = statSyncNoException(filePath)) {
|
||||
return stat.isFile();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
isSymbolicLinkSync: function(symlinkPath) {
|
||||
var stat;
|
||||
if (!isPathValid(symlinkPath)) {
|
||||
return false;
|
||||
}
|
||||
if (stat = lstatSyncNoException(symlinkPath)) {
|
||||
return stat.isSymbolicLink();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
isSymbolicLink: function(symlinkPath, callback) {
|
||||
if (isPathValid(symlinkPath)) {
|
||||
return fs.lstat(symlinkPath, function(error, stat) {
|
||||
return typeof callback === "function" ? callback((stat != null) && stat.isSymbolicLink()) : void 0;
|
||||
});
|
||||
} else {
|
||||
return process.nextTick(function() {
|
||||
return typeof callback === "function" ? callback(false) : void 0;
|
||||
});
|
||||
}
|
||||
},
|
||||
isExecutableSync: function(pathToCheck) {
|
||||
var stat;
|
||||
if (!isPathValid(pathToCheck)) {
|
||||
return false;
|
||||
}
|
||||
if (stat = statSyncNoException(pathToCheck)) {
|
||||
return (stat.mode & 0x1ff & 1) !== 0;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getSizeSync: function(pathToCheck) {
|
||||
var _ref;
|
||||
if (isPathValid(pathToCheck)) {
|
||||
return (_ref = statSyncNoException(pathToCheck).size) != null ? _ref : -1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
},
|
||||
listSync: function(rootPath, extensions) {
|
||||
var paths;
|
||||
if (!fsPlus.isDirectorySync(rootPath)) {
|
||||
return [];
|
||||
}
|
||||
paths = fs.readdirSync(rootPath);
|
||||
if (extensions) {
|
||||
paths = fsPlus.filterExtensions(paths, extensions);
|
||||
}
|
||||
paths = paths.sort(function(a, b) {
|
||||
return a.toLowerCase().localeCompare(b.toLowerCase());
|
||||
});
|
||||
paths = paths.map(function(childPath) {
|
||||
return path.join(rootPath, childPath);
|
||||
});
|
||||
return paths;
|
||||
},
|
||||
list: function() {
|
||||
var done, extensions, rest, rootPath;
|
||||
rootPath = arguments[0], rest = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
||||
if (rest.length > 1) {
|
||||
extensions = rest.shift();
|
||||
}
|
||||
done = rest.shift();
|
||||
return fs.readdir(rootPath, function(error, paths) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
} else {
|
||||
if (extensions) {
|
||||
paths = fsPlus.filterExtensions(paths, extensions);
|
||||
}
|
||||
paths = paths.sort(function(a, b) {
|
||||
return a.toLowerCase().localeCompare(b.toLowerCase());
|
||||
});
|
||||
paths = paths.map(function(childPath) {
|
||||
return path.join(rootPath, childPath);
|
||||
});
|
||||
return done(null, paths);
|
||||
}
|
||||
});
|
||||
},
|
||||
filterExtensions: function(paths, extensions) {
|
||||
extensions = extensions.map(function(ext) {
|
||||
if (ext === '') {
|
||||
return ext;
|
||||
} else {
|
||||
return '.' + ext.replace(/^\./, '');
|
||||
}
|
||||
});
|
||||
return paths.filter(function(pathToCheck) {
|
||||
return _.include(extensions, path.extname(pathToCheck));
|
||||
});
|
||||
},
|
||||
listTreeSync: function(rootPath) {
|
||||
var onPath, paths;
|
||||
paths = [];
|
||||
onPath = function(childPath) {
|
||||
paths.push(childPath);
|
||||
return true;
|
||||
};
|
||||
fsPlus.traverseTreeSync(rootPath, onPath, onPath);
|
||||
return paths;
|
||||
},
|
||||
move: function(source, target, callback) {
|
||||
return isMoveTargetValid(source, target, function(isMoveTargetValidErr, isTargetValid) {
|
||||
var error, targetParentPath;
|
||||
if (isMoveTargetValidErr) {
|
||||
callback(isMoveTargetValidErr);
|
||||
return;
|
||||
}
|
||||
if (!isTargetValid) {
|
||||
error = new Error("'" + target + "' already exists.");
|
||||
error.code = 'EEXIST';
|
||||
callback(error);
|
||||
return;
|
||||
}
|
||||
targetParentPath = path.dirname(target);
|
||||
return fs.exists(targetParentPath, function(targetParentExists) {
|
||||
if (targetParentExists) {
|
||||
fs.rename(source, target, callback);
|
||||
return;
|
||||
}
|
||||
return fsPlus.makeTree(targetParentPath, function(makeTreeErr) {
|
||||
if (makeTreeErr) {
|
||||
callback(makeTreeErr);
|
||||
return;
|
||||
}
|
||||
return fs.rename(source, target, callback);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
moveSync: function(source, target) {
|
||||
var error, targetParentPath;
|
||||
if (!isMoveTargetValidSync(source, target)) {
|
||||
error = new Error("'" + target + "' already exists.");
|
||||
error.code = 'EEXIST';
|
||||
throw error;
|
||||
}
|
||||
targetParentPath = path.dirname(target);
|
||||
if (!fs.existsSync(targetParentPath)) {
|
||||
fsPlus.makeTreeSync(targetParentPath);
|
||||
}
|
||||
return fs.renameSync(source, target);
|
||||
},
|
||||
removeSync: function(pathToRemove) {
|
||||
return rimraf.sync(pathToRemove);
|
||||
},
|
||||
remove: function(pathToRemove, callback) {
|
||||
return rimraf(pathToRemove, callback);
|
||||
},
|
||||
writeFileSync: function(filePath, content, options) {
|
||||
mkdirp.sync(path.dirname(filePath));
|
||||
return fs.writeFileSync(filePath, content, options);
|
||||
},
|
||||
writeFile: function(filePath, content, options, callback) {
|
||||
callback = _.last(arguments);
|
||||
return mkdirp(path.dirname(filePath), function(error) {
|
||||
if (error != null) {
|
||||
return typeof callback === "function" ? callback(error) : void 0;
|
||||
} else {
|
||||
return fs.writeFile(filePath, content, options, callback);
|
||||
}
|
||||
});
|
||||
},
|
||||
copy: function(sourcePath, destinationPath, done) {
|
||||
return mkdirp(path.dirname(destinationPath), function(error) {
|
||||
var destinationStream, sourceStream;
|
||||
if (error != null) {
|
||||
if (typeof done === "function") {
|
||||
done(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
sourceStream = fs.createReadStream(sourcePath);
|
||||
sourceStream.on('error', function(error) {
|
||||
if (typeof done === "function") {
|
||||
done(error);
|
||||
}
|
||||
return done = null;
|
||||
});
|
||||
destinationStream = fs.createWriteStream(destinationPath);
|
||||
destinationStream.on('error', function(error) {
|
||||
if (typeof done === "function") {
|
||||
done(error);
|
||||
}
|
||||
return done = null;
|
||||
});
|
||||
destinationStream.on('close', function() {
|
||||
if (typeof done === "function") {
|
||||
done();
|
||||
}
|
||||
return done = null;
|
||||
});
|
||||
return sourceStream.pipe(destinationStream);
|
||||
});
|
||||
},
|
||||
copySync: function(sourcePath, destinationPath) {
|
||||
var destinationFilePath, source, sourceFilePath, sources, _i, _len, _results;
|
||||
sources = fs.readdirSync(sourcePath);
|
||||
mkdirp.sync(destinationPath);
|
||||
_results = [];
|
||||
for (_i = 0, _len = sources.length; _i < _len; _i++) {
|
||||
source = sources[_i];
|
||||
sourceFilePath = path.join(sourcePath, source);
|
||||
destinationFilePath = path.join(destinationPath, source);
|
||||
if (fsPlus.isDirectorySync(sourceFilePath)) {
|
||||
_results.push(fsPlus.copySync(sourceFilePath, destinationFilePath));
|
||||
} else {
|
||||
_results.push(fsPlus.copyFileSync(sourceFilePath, destinationFilePath));
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
copyFileSync: function(sourceFilePath, destinationFilePath, bufferSize) {
|
||||
var buffer, bytesRead, position, readFd, writeFd, _results;
|
||||
if (bufferSize == null) {
|
||||
bufferSize = 16 * 1024;
|
||||
}
|
||||
mkdirp.sync(path.dirname(destinationFilePath));
|
||||
readFd = null;
|
||||
writeFd = null;
|
||||
try {
|
||||
readFd = fs.openSync(sourceFilePath, 'r');
|
||||
writeFd = fs.openSync(destinationFilePath, 'w');
|
||||
bytesRead = 1;
|
||||
position = 0;
|
||||
_results = [];
|
||||
while (bytesRead > 0) {
|
||||
buffer = new Buffer(bufferSize);
|
||||
bytesRead = fs.readSync(readFd, buffer, 0, buffer.length, position);
|
||||
fs.writeSync(writeFd, buffer, 0, bytesRead, position);
|
||||
_results.push(position += bytesRead);
|
||||
}
|
||||
return _results;
|
||||
} finally {
|
||||
if (readFd != null) {
|
||||
fs.closeSync(readFd);
|
||||
}
|
||||
if (writeFd != null) {
|
||||
fs.closeSync(writeFd);
|
||||
}
|
||||
}
|
||||
},
|
||||
makeTreeSync: function(directoryPath) {
|
||||
if (!fsPlus.isDirectorySync(directoryPath)) {
|
||||
return mkdirp.sync(directoryPath);
|
||||
}
|
||||
},
|
||||
makeTree: function(directoryPath, callback) {
|
||||
return fsPlus.isDirectory(directoryPath, function(exists) {
|
||||
if (exists) {
|
||||
return typeof callback === "function" ? callback() : void 0;
|
||||
}
|
||||
return mkdirp(directoryPath, function(error) {
|
||||
return typeof callback === "function" ? callback(error) : void 0;
|
||||
});
|
||||
});
|
||||
},
|
||||
traverseTreeSync: function(rootPath, onFile, onDirectory) {
|
||||
var traverse;
|
||||
if (onDirectory == null) {
|
||||
onDirectory = onFile;
|
||||
}
|
||||
if (!fsPlus.isDirectorySync(rootPath)) {
|
||||
return;
|
||||
}
|
||||
traverse = function(directoryPath, onFile, onDirectory) {
|
||||
var childPath, file, linkStats, stats, _i, _len, _ref;
|
||||
_ref = fs.readdirSync(directoryPath);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
file = _ref[_i];
|
||||
childPath = path.join(directoryPath, file);
|
||||
stats = fs.lstatSync(childPath);
|
||||
if (stats.isSymbolicLink()) {
|
||||
if (linkStats = statSyncNoException(childPath)) {
|
||||
stats = linkStats;
|
||||
}
|
||||
}
|
||||
if (stats.isDirectory()) {
|
||||
if (onDirectory(childPath)) {
|
||||
traverse(childPath, onFile, onDirectory);
|
||||
}
|
||||
} else if (stats.isFile()) {
|
||||
onFile(childPath);
|
||||
}
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
return traverse(rootPath, onFile, onDirectory);
|
||||
},
|
||||
traverseTree: function(rootPath, onFile, onDirectory, onDone) {
|
||||
return fs.readdir(rootPath, function(error, files) {
|
||||
var file, queue, _i, _len, _results;
|
||||
if (error) {
|
||||
return typeof onDone === "function" ? onDone() : void 0;
|
||||
} else {
|
||||
queue = async.queue(function(childPath, callback) {
|
||||
return fs.stat(childPath, function(error, stats) {
|
||||
if (error) {
|
||||
return callback(error);
|
||||
} else if (stats.isFile()) {
|
||||
onFile(childPath);
|
||||
return callback();
|
||||
} else if (stats.isDirectory()) {
|
||||
if (onDirectory(childPath)) {
|
||||
return fs.readdir(childPath, function(error, files) {
|
||||
var file, _i, _len;
|
||||
if (error) {
|
||||
return callback(error);
|
||||
} else {
|
||||
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
||||
file = files[_i];
|
||||
queue.unshift(path.join(childPath, file));
|
||||
}
|
||||
return callback();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
queue.concurrency = 1;
|
||||
queue.drain = onDone;
|
||||
_results = [];
|
||||
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
||||
file = files[_i];
|
||||
_results.push(queue.push(path.join(rootPath, file)));
|
||||
}
|
||||
return _results;
|
||||
}
|
||||
});
|
||||
},
|
||||
md5ForPath: function(pathToDigest) {
|
||||
var contents;
|
||||
contents = fs.readFileSync(pathToDigest);
|
||||
return require('crypto').createHash('md5').update(contents).digest('hex');
|
||||
},
|
||||
resolve: function() {
|
||||
var args, candidatePath, extensions, loadPath, loadPaths, pathToResolve, resolvedPath, _i, _len, _ref;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
if (_.isArray(_.last(args))) {
|
||||
extensions = args.pop();
|
||||
}
|
||||
pathToResolve = (_ref = args.pop()) != null ? _ref.toString() : void 0;
|
||||
loadPaths = args;
|
||||
if (!pathToResolve) {
|
||||
return void 0;
|
||||
}
|
||||
if (fsPlus.isAbsolute(pathToResolve)) {
|
||||
if (extensions && (resolvedPath = fsPlus.resolveExtension(pathToResolve, extensions))) {
|
||||
return resolvedPath;
|
||||
} else {
|
||||
if (fsPlus.existsSync(pathToResolve)) {
|
||||
return pathToResolve;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (_i = 0, _len = loadPaths.length; _i < _len; _i++) {
|
||||
loadPath = loadPaths[_i];
|
||||
candidatePath = path.join(loadPath, pathToResolve);
|
||||
if (extensions) {
|
||||
if (resolvedPath = fsPlus.resolveExtension(candidatePath, extensions)) {
|
||||
return resolvedPath;
|
||||
}
|
||||
} else {
|
||||
if (fsPlus.existsSync(candidatePath)) {
|
||||
return fsPlus.absolute(candidatePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
resolveOnLoadPath: function() {
|
||||
var args, loadPaths;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
loadPaths = Module.globalPaths.concat(module.paths);
|
||||
return fsPlus.resolve.apply(fsPlus, __slice.call(loadPaths).concat(__slice.call(args)));
|
||||
},
|
||||
resolveExtension: function(pathToResolve, extensions) {
|
||||
var extension, pathWithExtension, _i, _len;
|
||||
for (_i = 0, _len = extensions.length; _i < _len; _i++) {
|
||||
extension = extensions[_i];
|
||||
if (extension === "") {
|
||||
if (fsPlus.existsSync(pathToResolve)) {
|
||||
return fsPlus.absolute(pathToResolve);
|
||||
}
|
||||
} else {
|
||||
pathWithExtension = pathToResolve + "." + extension.replace(/^\./, "");
|
||||
if (fsPlus.existsSync(pathWithExtension)) {
|
||||
return fsPlus.absolute(pathWithExtension);
|
||||
}
|
||||
}
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
isCompressedExtension: function(ext) {
|
||||
if (ext == null) {
|
||||
return false;
|
||||
}
|
||||
return COMPRESSED_EXTENSIONS.hasOwnProperty(ext.toLowerCase());
|
||||
},
|
||||
isImageExtension: function(ext) {
|
||||
if (ext == null) {
|
||||
return false;
|
||||
}
|
||||
return IMAGE_EXTENSIONS.hasOwnProperty(ext.toLowerCase());
|
||||
},
|
||||
isPdfExtension: function(ext) {
|
||||
return (ext != null ? ext.toLowerCase() : void 0) === '.pdf';
|
||||
},
|
||||
isBinaryExtension: function(ext) {
|
||||
if (ext == null) {
|
||||
return false;
|
||||
}
|
||||
return BINARY_EXTENSIONS.hasOwnProperty(ext.toLowerCase());
|
||||
},
|
||||
isReadmePath: function(readmePath) {
|
||||
var base, extension;
|
||||
extension = path.extname(readmePath);
|
||||
base = path.basename(readmePath, extension).toLowerCase();
|
||||
return base === 'readme' && (extension === '' || fsPlus.isMarkdownExtension(extension));
|
||||
},
|
||||
isMarkdownExtension: function(ext) {
|
||||
if (ext == null) {
|
||||
return false;
|
||||
}
|
||||
return MARKDOWN_EXTENSIONS.hasOwnProperty(ext.toLowerCase());
|
||||
},
|
||||
isCaseInsensitive: function() {
|
||||
var lowerCaseStat, upperCaseStat;
|
||||
if (fsPlus.caseInsensitiveFs == null) {
|
||||
lowerCaseStat = statSyncNoException(process.execPath.toLowerCase());
|
||||
upperCaseStat = statSyncNoException(process.execPath.toUpperCase());
|
||||
if (lowerCaseStat && upperCaseStat) {
|
||||
fsPlus.caseInsensitiveFs = lowerCaseStat.dev === upperCaseStat.dev && lowerCaseStat.ino === upperCaseStat.ino;
|
||||
} else {
|
||||
fsPlus.caseInsensitiveFs = false;
|
||||
}
|
||||
}
|
||||
return fsPlus.caseInsensitiveFs;
|
||||
},
|
||||
isCaseSensitive: function() {
|
||||
return !fsPlus.isCaseInsensitive();
|
||||
}
|
||||
};
|
||||
|
||||
statSyncNoException = fs.statSyncNoException, lstatSyncNoException = fs.lstatSyncNoException;
|
||||
|
||||
if (statSyncNoException == null) {
|
||||
statSyncNoException = function() {
|
||||
var args, error;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
try {
|
||||
return fs.statSync.apply(fs, args);
|
||||
} catch (_error) {
|
||||
error = _error;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (lstatSyncNoException == null) {
|
||||
lstatSyncNoException = function() {
|
||||
var args, error;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
try {
|
||||
return fs.lstatSync.apply(fs, args);
|
||||
} catch (_error) {
|
||||
error = _error;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
BINARY_EXTENSIONS = {
|
||||
'.ds_store': true,
|
||||
'.a': true,
|
||||
'.exe': true,
|
||||
'.o': true,
|
||||
'.pyc': true,
|
||||
'.pyo': true,
|
||||
'.so': true,
|
||||
'.woff': true
|
||||
};
|
||||
|
||||
COMPRESSED_EXTENSIONS = {
|
||||
'.bz2': true,
|
||||
'.egg': true,
|
||||
'.epub': true,
|
||||
'.gem': true,
|
||||
'.gz': true,
|
||||
'.jar': true,
|
||||
'.lz': true,
|
||||
'.lzma': true,
|
||||
'.lzo': true,
|
||||
'.rar': true,
|
||||
'.tar': true,
|
||||
'.tgz': true,
|
||||
'.war': true,
|
||||
'.whl': true,
|
||||
'.xpi': true,
|
||||
'.xz': true,
|
||||
'.z': true,
|
||||
'.zip': true
|
||||
};
|
||||
|
||||
IMAGE_EXTENSIONS = {
|
||||
'.gif': true,
|
||||
'.ico': true,
|
||||
'.jpeg': true,
|
||||
'.jpg': true,
|
||||
'.png': true,
|
||||
'.tif': true,
|
||||
'.tiff': true,
|
||||
'.webp': true
|
||||
};
|
||||
|
||||
MARKDOWN_EXTENSIONS = {
|
||||
'.markdown': true,
|
||||
'.md': true,
|
||||
'.mdown': true,
|
||||
'.mkd': true,
|
||||
'.mkdown': true,
|
||||
'.rmd': true,
|
||||
'.ron': true
|
||||
};
|
||||
|
||||
isPathValid = function(pathToCheck) {
|
||||
return (pathToCheck != null) && typeof pathToCheck === 'string' && pathToCheck.length > 0;
|
||||
};
|
||||
|
||||
isMoveTargetValid = function(source, target, callback) {
|
||||
return fs.stat(source, function(oldErr, oldStat) {
|
||||
if (oldErr) {
|
||||
callback(oldErr);
|
||||
return;
|
||||
}
|
||||
return fs.stat(target, function(newErr, newStat) {
|
||||
if (newErr && newErr.code === 'ENOENT') {
|
||||
callback(void 0, true);
|
||||
return;
|
||||
}
|
||||
return callback(void 0, source.toLowerCase() === target.toLowerCase() && oldStat.dev === newStat.dev && oldStat.ino === newStat.ino);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
isMoveTargetValidSync = function(source, target) {
|
||||
var newStat, oldStat;
|
||||
oldStat = statSyncNoException(source);
|
||||
newStat = statSyncNoException(target);
|
||||
if (!(oldStat && newStat)) {
|
||||
return true;
|
||||
}
|
||||
return source.toLowerCase() === target.toLowerCase() && oldStat.dev === newStat.dev && oldStat.ino === newStat.ino;
|
||||
};
|
||||
|
||||
module.exports = _.extend({}, fs, fsPlus);
|
||||
|
||||
}).call(this);
|
||||
38
node_modules/fs-plus/package.json
generated
vendored
Normal file
38
node_modules/fs-plus/package.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "fs-plus",
|
||||
"version": "2.10.1",
|
||||
"description": "node's fs with more helpers",
|
||||
"main": "./lib/fs-plus.js",
|
||||
"scripts": {
|
||||
"prepublish": "grunt prepublish",
|
||||
"test": "grunt test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/atom/fs-plus.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/atom/fs-plus/issues"
|
||||
},
|
||||
"homepage": "http://atom.github.io/fs-plus",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"fs",
|
||||
"filesystem"
|
||||
],
|
||||
"devDependencies": {
|
||||
"jasmine-focused": "1.x",
|
||||
"grunt-contrib-coffee": "~0.9.0",
|
||||
"grunt-cli": "~0.1.8",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-shell": "~0.2.2",
|
||||
"grunt-coffeelint": "0.0.6",
|
||||
"temp": "~0.8.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"async": "^1.5.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
"rimraf": "^2.5.2",
|
||||
"underscore-plus": "1.x"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user