Skip to content
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

Merged
merged 3 commits into from Mar 3, 2017
Merged

[TIMOB-23948] Remove wrench in favor of fs-extra #120

merged 3 commits into from Mar 3, 2017

Conversation

hansemannn
Copy link
Contributor

@hansemannn hansemannn commented Feb 3, 2017

(Work in Progress)

Note: When building (./build.sh), there are still some warnings due to the titanium dependency:

npm WARN deprecated wrench@1.5.9: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
npm WARN deprecated wrench@1.5.8: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130

But those should rather be replaced in the SDK.

Copy link
Contributor

@janvennemann janvennemann left a 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

@@ -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);
Copy link
Contributor

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

}
wrench.mkdirSyncRecursive(buildDir);
fs.mkdirsSync(buildDir);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@hansemannn
Copy link
Contributor Author

hansemannn commented Feb 16, 2017

@janvennemann All addressed.

Copy link
Contributor

@janvennemann janvennemann left a 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);
Copy link
Contributor

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);
Copy link
Contributor

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

@@ -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);
}
Copy link
Contributor

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);
Copy link
Contributor

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);
}
Copy link
Contributor

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

@hansemannn
Copy link
Contributor Author

Addressed

@janvennemann janvennemann merged commit e0f6d8c into tidev:master Mar 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants