-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-23948] Remove wrench in favor of fs-extra #120
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,8 @@ exports.cliVersion = '>=3.2'; | |
(function () { | ||
var path = require('path'), | ||
findit = require('findit'), | ||
fs = require('fs'), | ||
chalk = require('chalk'), | ||
wrench = require('wrench'), | ||
fs = require('fs-extra'), | ||
appc = require('node-appc'), | ||
DOMParser = require('xmldom').DOMParser, | ||
async = require('async'), | ||
|
@@ -86,20 +85,20 @@ exports.cliVersion = '>=3.2'; | |
fs.mkdirSync(buildDir); | ||
} | ||
else if (afs.exists(buildPlatform)) { | ||
wrench.rmdirSyncRecursive(buildPlatform); | ||
fs.removeSync(buildPlatform); | ||
} | ||
if (!afs.exists(resourcesDir)) { | ||
fs.mkdirSync(resourcesDir); | ||
} | ||
// Wipe hyperloop resources each time, we will re-generate | ||
if (afs.exists(hyperloopResources)) { | ||
wrench.rmdirSyncRecursive(hyperloopResources); | ||
fs.removeSync(hyperloopResources); | ||
} | ||
|
||
// create a temporary hyperloop directory | ||
hyperloopBuildDir = path.join(buildDir, 'hyperloop', 'android'); | ||
if (!afs.exists(hyperloopBuildDir)) { | ||
wrench.mkdirSyncRecursive(hyperloopBuildDir); | ||
fs.mkdirsSync(hyperloopBuildDir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocks like this can be replaced with |
||
} | ||
|
||
// check to make sure the hyperloop module is actually configured | ||
|
@@ -167,7 +166,7 @@ exports.cliVersion = '>=3.2'; | |
fs.unlinkSync(fn); | ||
}); | ||
|
||
wrench.rmdirSyncRecursive(filesDir); | ||
fs.removeSync(filesDir); | ||
finished(); | ||
} | ||
}); | ||
|
@@ -351,10 +350,10 @@ exports.cliVersion = '>=3.2'; | |
foundJars = [path.join(extractedDir, 'classes.jar')]; | ||
|
||
if (afs.exists(extractedDir)) { | ||
wrench.rmdirSyncRecursive(extractedDir); | ||
fs.removeSync(extractedDir); | ||
} | ||
// Create destination dir | ||
wrench.mkdirSyncRecursive(extractedDir); | ||
fs.mkdirsSync(extractedDir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace if block above and |
||
|
||
async.series([ | ||
// Unzip aar file to destination | ||
|
@@ -417,7 +416,7 @@ exports.cliVersion = '>=3.2'; | |
} | ||
var dest = path.join(buildLibs, path.relative(jniDir, file)); | ||
// make dest dir | ||
wrench.mkdirSyncRecursive(path.dirname(dest)); | ||
fs.mkdirsSync(path.dirname(dest)); | ||
// copy .so over | ||
afs.copyFileSync(file, dest, {logger: logger}); | ||
}) | ||
|
@@ -438,7 +437,7 @@ exports.cliVersion = '>=3.2'; | |
var keys = Object.keys(references); | ||
// only if we found references, otherwise, skip | ||
if (keys.length) { | ||
wrench.mkdirSyncRecursive(hyperloopResources); | ||
fs.mkdirsSync(hyperloopResources); | ||
afs.copyDirRecursive(filesDir, hyperloopResources, function (err) { | ||
logger.info('Finished ' + HL + ' assembly'); | ||
if (err) { | ||
|
@@ -551,7 +550,7 @@ exports.cliVersion = '>=3.2'; | |
|
||
filesDir = path.join(hyperloopBuildDir, 'js'); | ||
if (!afs.exists(filesDir)) { | ||
wrench.mkdirSyncRecursive(filesDir); | ||
fs.mkdirsSync(filesDir); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace if block with |
||
|
||
// drop hyperloop/ from each entry in references to get just the class names | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,7 @@ | |
* Android hyperloop JS proxy generation. | ||
*/ | ||
var metabase = require('./metabase'), | ||
fs = require('fs'), | ||
wrench = require('wrench'), | ||
fs = require('fs-extra'), | ||
path = require('path'), | ||
async = require('async'), | ||
ejs = require('ejs'), | ||
|
@@ -170,7 +169,7 @@ function generateFromJSON(dir, metabaseJSON, classes, callback) { | |
packages = {}; | ||
|
||
if (fs.existsSync(dir)) { | ||
wrench.rmdirSyncRecursive(dir); | ||
fs.removeSync(dir); | ||
} | ||
fs.mkdirSync(dir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace this and the if block with |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,10 @@ var coreLib = { | |
var path = require('path'), | ||
exec = require('child_process').exec, | ||
hm = require('hyperloop-metabase'), | ||
fs = require('fs'), | ||
fs = require('fs-extra'), | ||
crypto = require('crypto'), | ||
chalk = hm.chalk, | ||
async = hm.async, | ||
wrench = hm.wrench, | ||
HL = chalk.magenta.inverse('Hyperloop'); | ||
|
||
/** | ||
|
@@ -178,7 +177,7 @@ HyperloopiOSBuilder.prototype.validate = function validate() { | |
HyperloopiOSBuilder.prototype.setup = function setup() { | ||
// create a temporary hyperloop directory | ||
if (!fs.existsSync(this.hyperloopBuildDir)) { | ||
wrench.mkdirSyncRecursive(this.hyperloopBuildDir); | ||
fs.mkdirsSync(this.hyperloopBuildDir); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace with |
||
|
||
// update to use the correct libhyperloop based on which JS engine is configured | ||
|
@@ -473,7 +472,7 @@ HyperloopiOSBuilder.prototype.generateSourceFiles = function generateSourceFiles | |
return callback(); | ||
} | ||
|
||
fs.existsSync(this.hyperloopJSDir) || wrench.mkdirSyncRecursive(this.hyperloopJSDir); | ||
fs.existsSync(this.hyperloopJSDir) || fs.mkdirsSync(this.hyperloopJSDir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace this with |
||
|
||
if (this.builder.forceCleanBuild || this.forceMetabase) { | ||
this.logger.trace('Forcing a metabase rebuild'); | ||
|
@@ -652,7 +651,7 @@ HyperloopiOSBuilder.prototype.copyHyperloopJSFiles = function copyHyperloopJSFil | |
|
||
if (changed) { | ||
logger.debug('Writing ' + chalk.cyan(destFile)); | ||
fs.existsSync(destDir) || wrench.mkdirSyncRecursive(destDir); | ||
fs.ensureDirSync(destDir); | ||
fs.writeFileSync(destFile, contents || fs.readFileSync(srcFile).toString()); | ||
} else { | ||
logger.trace('No change, skipping ' + chalk.cyan(destFile)); | ||
|
@@ -1044,7 +1043,7 @@ HyperloopiOSBuilder.prototype.updateXcodeProject = function updateXcodeProject() | |
this.forceRebuild = true; | ||
} | ||
this.logger.debug(__('Writing %s', dest.cyan)); | ||
fs.existsSync(parent) || wrench.mkdirSyncRecursive(parent); | ||
fs.ensureDirSync(parent); | ||
fs.writeFileSync(dest, contents); | ||
} else { | ||
this.logger.trace(__('No change, skipping %s', dest.cyan)); | ||
|
@@ -1113,7 +1112,7 @@ HyperloopiOSBuilder.prototype.hookRemoveFiles = function hookRemoveFiles(data) { | |
// remove empty Framework directory that might have been created by cocoapods | ||
var frameworksDir = path.join(this.builder.xcodeAppDir, 'Frameworks'); | ||
if (fs.existsSync(frameworksDir) && fs.readdirSync(frameworksDir).length === 0) { | ||
wrench.rmdirSyncRecursive(frameworksDir); | ||
fs.removeSync(frameworksDir); | ||
} | ||
if (this.hasCocoaPods) { | ||
var productsDirectory = path.resolve(this.builder.xcodeAppDir, '..'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,6 @@ | |
"plist": "^1.1.0", | ||
"semver": "^5.0.3", | ||
"walk-ast": "0.0.2", | ||
"wrench": "^1.5.8" | ||
"fs-extra": "^2.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
var should = require('should'), | ||
helper = require('./helper'), | ||
utillib = require('util'), | ||
fs = require('fs'), | ||
fs = require('fs-extra'), | ||
metabase = require('../lib/metabase'), | ||
generator = require('../lib/generate/index'), | ||
util = require('../lib/generate/util'), | ||
nodePath = require('path'), | ||
wrench = require('wrench'), | ||
buildDir = nodePath.join(__dirname, '..', 'build', 'hyperloop'); | ||
|
||
function Hyperloop () { | ||
|
@@ -74,9 +73,9 @@ describe('generate', function () { | |
global.HyperloopObject = HyperloopObject; | ||
|
||
if (fs.existsSync(buildDir)) { | ||
wrench.rmdirSyncRecursive(buildDir); | ||
fs.removeSync(buildDir); | ||
} | ||
wrench.mkdirSyncRecursive(buildDir); | ||
fs.mkdirsSync(buildDir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can replace this block with |
||
}); | ||
|
||
before(function () { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,11 @@ | |
* Copyright (c) 2015 by Appcelerator, Inc. All Rights Reserved. | ||
*/ | ||
var path = require('path'), | ||
fs = require('fs'), | ||
fs = require('fs-extra'), | ||
async = require('async'), | ||
http = require('http'), | ||
request = require('request'), | ||
colors = require('colors'), | ||
wrench = require('wrench'), | ||
temp = require('temp'), | ||
appc = require('node-appc'), | ||
exec = require('child_process').exec, | ||
|
@@ -30,7 +29,7 @@ function downloadURL(url, callback) { | |
|
||
var tempName = temp.path({ suffix: '.zip' }), | ||
tempDir = path.dirname(tempName); | ||
fs.existsSync(tempDir) || wrench.mkdirSyncRecursive(tempDir); | ||
fs.existsSync(tempDir) || fs.removeSync(tempDir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you accidentally replaced |
||
|
||
var tempStream = fs.createWriteStream(tempName), | ||
req = request({ url: url }); | ||
|
@@ -414,9 +413,9 @@ function build(branch, callback) { | |
async.series([ | ||
function (next) { | ||
if (fs.existsSync(buildTempDir)) { | ||
wrench.rmdirSyncRecursive(buildTempDir); | ||
fs.removeSync(buildTempDir); | ||
} | ||
wrench.mkdirSyncRecursive(buildTempDir); | ||
fs.mkdirsSync(buildTempDir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace this block with |
||
next(); | ||
}, | ||
// Install latest Titanium SDK | ||
|
@@ -510,7 +509,7 @@ function build(branch, callback) { | |
writeAndroidPluginPackage, | ||
runBuildScript, | ||
function (next) { | ||
wrench.rmdirSyncRecursive(buildTempDir); | ||
fs.removeSync(buildTempDir); | ||
next(); | ||
}, | ||
// TODO Remove the Titanium SDK we installed to avoid cluttering up HDD? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocks like this can be replaced with
emptyDirSync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emptyDirSync
only empties the directory, it doesn't delete it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you are right, i didn't check it will only get created if needed. Just ignore this comment.