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
Conversation
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.
I left some comments about additional stuff that can be replaced now that we use fs-extra
iphone/plugin/hyperloop.js
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this with ensureDirSync
like you did in line 654
metabase/ios/test/generate_test.js
Outdated
} | ||
wrench.mkdirSyncRecursive(buildDir); | ||
fs.mkdirsSync(buildDir); |
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.
You can replace this block with emptyDirSync
tools/ci.js
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you accidentally replaced mkdirSyncRecursive
with removeSync
? Also ensureDirSync
is probably a good use here.
tools/ci.js
Outdated
} | ||
wrench.mkdirSyncRecursive(buildTempDir); | ||
fs.mkdirsSync(buildTempDir); |
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.
Replace this block with emptyDirSync
} | ||
|
||
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Blocks like this can be replaced with ensureDirSync
} | ||
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); |
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.
@janvennemann All addressed. |
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.
Found a few other obsolete if blocks that can be replaced with fs-extra functionality
} | ||
// Create destination dir | ||
wrench.mkdirSyncRecursive(extractedDir); | ||
fs.mkdirsSync(extractedDir); |
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.
Replace if block above and mkdirSync
with emptyDirSync
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this and the if block with emptyDirSync
iphone/plugin/hyperloop.js
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with ensureDirSync
tools/ci.js
Outdated
} | ||
wrench.mkdirSyncRecursive(buildTempDir); | ||
fs.emptyDirSync(buildTempDir); |
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.
The if block is not necessary when using emptyDirSync
@@ -551,7 +548,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 comment
The reason will be displayed to describe this comment to others. Learn more.
Replace if block with ensureDirSync
Addressed |
(Work in Progress)
Note: When building (
./build.sh
), there are still some warnings due to thetitanium
dependency:But those should rather be replaced in the SDK.