Merge pull request #5150 from fredj/rm_wrench
Use fs-extra instead of wrench
This commit is contained in:
@@ -67,8 +67,7 @@
|
||||
"proj4": "2.3.14",
|
||||
"resemblejs": "2.2.0",
|
||||
"sinon": "1.17.3",
|
||||
"slimerjs": "0.906.1",
|
||||
"wrench": "1.5.8"
|
||||
"slimerjs": "0.906.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "openlayers",
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var fse = require('fs-extra');
|
||||
var istanbul = require('istanbul');
|
||||
var wrench = require('wrench');
|
||||
var path = require('path');
|
||||
var glob = require('glob');
|
||||
|
||||
@@ -28,17 +28,10 @@ var collector = new istanbul.Collector();
|
||||
|
||||
// General options used for the resource shuffling / directory copying
|
||||
var copyOpts = {
|
||||
// Whether to overwrite existing directory or not
|
||||
forceDelete: true,
|
||||
// Whether to copy hidden Unix files or not (preceding .)
|
||||
excludeHiddenUnix: false,
|
||||
// If we're overwriting something and the file already exists, keep the
|
||||
// existing
|
||||
preserveFiles: false,
|
||||
// Overwrite existing file or directory
|
||||
clobber: true,
|
||||
// Preserve the mtime and atime when copying files
|
||||
preserveTimestamps: true,
|
||||
// Whether to follow symlinks or not when copying files
|
||||
inflateSymlinks: false
|
||||
preserveTimestamps: true
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -49,28 +42,6 @@ var log = function(msg) {
|
||||
process.stdout.write(msg + '\n');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A utility method to recursively delete a non-empty folder.
|
||||
*
|
||||
* See http://www.geedew.com/remove-a-directory-that-is-not-empty-in-nodejs/
|
||||
* adjusted to use path.join
|
||||
* @param {string} p Path to the directory.
|
||||
*/
|
||||
var deleteFolderRecursive = function(p) {
|
||||
if (fs.existsSync(p)) {
|
||||
fs.readdirSync(p).forEach(function(file,index) {
|
||||
var curPath = path.join(p, file);
|
||||
if (fs.lstatSync(curPath).isDirectory()) { // recurse
|
||||
deleteFolderRecursive(curPath);
|
||||
} else { // delete file
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(p);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates folders for backup and instrumentation and copies the contents of the
|
||||
* current src folder into them.
|
||||
@@ -87,9 +58,9 @@ var setupBackupAndInstrumentationDir = function() {
|
||||
}
|
||||
|
||||
log('• copy src files to backup folder');
|
||||
wrench.copyDirSyncRecursive(dir, backupDir, copyOpts);
|
||||
fse.copySync(dir, backupDir, copyOpts);
|
||||
log('• copy src files to instrumentation folder');
|
||||
wrench.copyDirSyncRecursive(dir, instrumentedDir, copyOpts);
|
||||
fse.copySync(dir, instrumentedDir, copyOpts);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -99,11 +70,11 @@ var setupBackupAndInstrumentationDir = function() {
|
||||
*/
|
||||
var revertBackupAndInstrumentationDir = function() {
|
||||
log('• copy original src back to src folder');
|
||||
wrench.copyDirSyncRecursive(backupDir, dir, copyOpts);
|
||||
fse.copySync(backupDir, dir, copyOpts);
|
||||
log('• delete backup directory');
|
||||
deleteFolderRecursive(backupDir);
|
||||
fse.removeSync(backupDir);
|
||||
log('• delete instrumentation directory');
|
||||
deleteFolderRecursive(instrumentedDir);
|
||||
fse.removeSync(instrumentedDir);
|
||||
};
|
||||
|
||||
|
||||
@@ -161,7 +132,7 @@ var foundAllJavaScriptSourceFiles = function(err, files) {
|
||||
log(' • done. ' + cnt + ' files instrumented');
|
||||
log('• copy instrumented src back to src folder');
|
||||
|
||||
wrench.copyDirSyncRecursive(instrumentedDir, dir, copyOpts);
|
||||
fse.copySync(instrumentedDir, dir, copyOpts);
|
||||
|
||||
log('• run test suite on instrumented code');
|
||||
runTestsuite({coverage: true, reporter: 'dot'}, collectAndWriteCoverageData);
|
||||
|
||||
Reference in New Issue
Block a user