Skip to content

Commit 9ea8b62

Browse files
fix: ensure temp files are deleted
Ensure the temp files created by nativescript-doctor are deleted
1 parent c9f7d86 commit 9ea8b62

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

lib/sys-info.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,15 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
275275
try {
276276
const spawnResult = await this.childProcess.spawnFromEvent("pod", ["install"], "exit", { spawnOptions: { cwd: xcodeProjectDir } });
277277
if (spawnResult.exitCode) {
278+
this.fileSystem.deleteEntry(tempDirectory);
278279
return false;
279280
} else {
280-
return this.fileSystem.exists(path.join(xcodeProjectDir, "cocoapods.xcworkspace"));
281+
const exists = this.fileSystem.exists(path.join(xcodeProjectDir, "cocoapods.xcworkspace"));
282+
this.fileSystem.deleteEntry(tempDirectory);
283+
return exists;
281284
}
282285
} catch (err) {
286+
this.fileSystem.deleteEntry(tempDirectory);
283287
return null;
284288
}
285289
} else {

lib/wrappers/file-system.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as fs from "fs";
22
import * as path from "path";
33
import * as yauzl from "yauzl";
44
import * as util from "util";
5+
import * as shelljs from "shelljs";
56

67
const access = util.promisify(fs.access);
78
const mkdir = util.promisify(fs.mkdir);
@@ -58,6 +59,10 @@ export class FileSystem {
5859
const content = fs.readFileSync(filePath, options);
5960
return JSON.parse(content.toString());
6061
}
62+
63+
public deleteEntry(filePath: string): void {
64+
shelljs.rm("-rf", filePath);
65+
}
6166
}
6267

6368
function createParentDirsIfNeeded(filePath: string) {

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@types/mocha": "2.2.32",
2929
"@types/rimraf": "2.0.2",
3030
"@types/semver": "5.5.0",
31+
"@types/shelljs": "0.8.6",
3132
"@types/temp": "0.8.29",
3233
"@types/winreg": "1.2.30",
3334
"@types/yauzl": "2.9.0",
@@ -49,8 +50,9 @@
4950
"lodash": "4.17.15",
5051
"osenv": "0.1.3",
5152
"semver": "5.5.1",
53+
"shelljs": "0.7.6",
5254
"temp": "0.8.3",
5355
"winreg": "1.2.2",
5456
"yauzl": "2.10.0"
5557
}
56-
}
58+
}

0 commit comments

Comments
 (0)