Skip to content

Commit 6e698e9

Browse files
Make fs.deleteDirectory sync
1 parent 2591b76 commit 6e698e9

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

lib/services/android-project-service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
182182
.map(dir => path.join(resDestinationDir, dir.dirName));
183183
this.$logger.trace("Directories to clean:");
184184
this.$logger.trace(directoriesToClean);
185-
Future.wait(_.map(directoriesToClean, dir => this.$fs.deleteDirectory(dir)));
185+
_.map(directoriesToClean, dir => this.$fs.deleteDirectory(dir));
186186
}).future<void>()();
187187
}
188188

@@ -327,7 +327,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
327327
let valuesDirRegExp = /^values/;
328328
let resourcesDirs = this.$fs.readDirectory(resourcesDirPath).wait().filter(resDir => !resDir.match(valuesDirRegExp));
329329
_.each(resourcesDirs, resourceDir => {
330-
this.$fs.deleteDirectory(path.join(this.getAppResourcesDestinationDirectoryPath().wait(), resourceDir)).wait();
330+
this.$fs.deleteDirectory(path.join(this.getAppResourcesDestinationDirectoryPath().wait(), resourceDir));
331331
});
332332
}).future<void>()();
333333
}
@@ -372,11 +372,12 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
372372
}).future<void>()();
373373
}
374374

375+
// TODO: Remove IFuture, reason: fs.deleteDirectory - blocked as the other implementation of the interface has async operations.
375376
public removePluginNativeCode(pluginData: IPluginData): IFuture<void> {
376377
return (() => {
377378
try {
378-
this.$fs.deleteDirectory(path.join(this.platformData.projectRoot, "configurations", pluginData.name)).wait();
379-
this.$fs.deleteDirectory(path.join(this.platformData.projectRoot, "src", pluginData.name)).wait();
379+
this.$fs.deleteDirectory(path.join(this.platformData.projectRoot, "configurations", pluginData.name));
380+
this.$fs.deleteDirectory(path.join(this.platformData.projectRoot, "src", pluginData.name));
380381
} catch (e) {
381382
if (e.code === "ENOENT") {
382383
this.$logger.debug("No native code jars found: " + e.message);

lib/services/app-files-updater.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class AppFilesUpdater {
4747
}
4848

4949
protected deleteDestinationItem(directoryItem: string): void {
50-
this.fs.deleteDirectory(path.join(this.appDestinationDirectoryPath, directoryItem)).wait();
50+
this.fs.deleteDirectory(path.join(this.appDestinationDirectoryPath, directoryItem));
5151
}
5252

5353
protected readSourceDir(): string[] {

lib/services/ios-project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
541541

542542
filterFile(this.platformData.configurationFileName);
543543

544-
this.$fs.deleteDirectory(this.getAppResourcesDestinationDirectoryPath().wait()).wait();
544+
this.$fs.deleteDirectory(this.getAppResourcesDestinationDirectoryPath().wait());
545545
}).future<void>()();
546546
}
547547

lib/services/platform-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class PlatformService implements IPlatformService {
101101
let coreModuleName = this.addPlatformCore(platformData, frameworkDir).wait();
102102
this.$npm.uninstall(coreModuleName, {save: true}, this.$projectData.projectDir).wait();
103103
} catch (err) {
104-
this.$fs.deleteDirectory(platformPath).wait();
104+
this.$fs.deleteDirectory(platformPath);
105105
throw err;
106106
} finally {
107107
spinner.stop();
@@ -292,7 +292,7 @@ export class PlatformService implements IPlatformService {
292292
let appResourcesDestination = platformData.platformProjectService.getAppResourcesDestinationDirectoryPath().wait();
293293
this.$fs.ensureDirectoryExists(appResourcesDestination).wait();
294294
shell.cp("-Rf", path.join(appResourcesDirectoryPath, platformData.normalizedPlatformName, "*"), appResourcesDestination);
295-
this.$fs.deleteDirectory(appResourcesDirectoryPath).wait();
295+
this.$fs.deleteDirectory(appResourcesDirectoryPath);
296296
}
297297
}).future<void>()();
298298
}
@@ -406,7 +406,7 @@ export class PlatformService implements IPlatformService {
406406
let platformData = this.$platformsData.getPlatformData(platform);
407407

408408
let platformDir = path.join(this.$projectData.platformsDir, platform);
409-
this.$fs.deleteDirectory(platformDir).wait();
409+
this.$fs.deleteDirectory(platformDir);
410410
this.$projectDataService.removeProperty(platformData.frameworkPackageName).wait();
411411

412412
this.$logger.out(`Platform ${platform} successfully removed.`);

lib/services/project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class ProjectService implements IProjectService {
8585
// TODO: plamen5kov: remove later (put only so tests pass (need to fix tests))
8686
this.$logger.trace(`Using NativeScript verified template: ${templateName} with version undefined.`);
8787
} catch (err) {
88-
this.$fs.deleteDirectory(projectDir).wait();
88+
this.$fs.deleteDirectory(projectDir);
8989
throw err;
9090
}
9191
this.$logger.printMarkdown("Project `%s` was successfully created.", projectName);

lib/services/project-templates-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class ProjectTemplatesService implements IProjectTemplatesService {
3434

3535
if(realTemplatePath) {
3636
//this removes dependencies from templates so they are not copied to app folder
37-
this.$fs.deleteDirectory(path.join(realTemplatePath, constants.NODE_MODULES_FOLDER_NAME)).wait();
37+
this.$fs.deleteDirectory(path.join(realTemplatePath, constants.NODE_MODULES_FOLDER_NAME));
3838
return realTemplatePath;
3939
}
4040

lib/tools/node-modules/node-modules-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class NodeModulesBuilder implements INodeModulesBuilder {
102102
let tnsModulesPath = path.join(projectDir, constants.NODE_MODULES_FOLDER_NAME, constants.TNS_CORE_MODULES_NAME);
103103
let tnsModulesInApp = this.$fs.readDirectory(tnsModulesPath).wait();
104104
let modulesToDelete = _.difference(currentPreparedTnsModules, tnsModulesInApp);
105-
_.each(modulesToDelete, moduleName => this.$fs.deleteDirectory(path.join(absoluteOutputPath, moduleName)).wait());
105+
_.each(modulesToDelete, moduleName => this.$fs.deleteDirectory(path.join(absoluteOutputPath, moduleName)));
106106
}
107107

108108
if (!lastModifiedTime || isNodeModulesModified) {

test/project-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe("Project Service Tests", () => {
155155
}).wait();
156156
npmInstallationManager.install("tns-template-hello-world", defaultTemplateDir, {dependencyType: "save"}).wait();
157157
defaultTemplatePath = path.join(defaultTemplateDir, "node_modules", "tns-template-hello-world");
158-
fs.deleteDirectory(path.join(defaultTemplatePath, "node_modules")).wait();
158+
fs.deleteDirectory(path.join(defaultTemplatePath, "node_modules"));
159159

160160
let defaultSpecificVersionTemplateDir = temp.mkdirSync("defaultTemplateSpeciffic");
161161
fs.writeJson(path.join(defaultSpecificVersionTemplateDir, "package.json"), {
@@ -168,7 +168,7 @@ describe("Project Service Tests", () => {
168168
}).wait();
169169
npmInstallationManager.install("tns-template-hello-world", defaultSpecificVersionTemplateDir, {version: "1.4.0", dependencyType: "save"}).wait();
170170
defaultSpecificVersionTemplatePath = path.join(defaultSpecificVersionTemplateDir, "node_modules", "tns-template-hello-world");
171-
fs.deleteDirectory(path.join(defaultSpecificVersionTemplatePath, "node_modules")).wait();
171+
fs.deleteDirectory(path.join(defaultSpecificVersionTemplatePath, "node_modules"));
172172

173173
let angularTemplateDir = temp.mkdirSync("angularTemplate");
174174
fs.writeJson(path.join(angularTemplateDir, "package.json"), {
@@ -181,7 +181,7 @@ describe("Project Service Tests", () => {
181181
}).wait();
182182
npmInstallationManager.install("tns-template-hello-world-ng", angularTemplateDir, {dependencyType: "save"}).wait();
183183
angularTemplatePath = path.join(angularTemplateDir, "node_modules", "tns-template-hello-world-ng");
184-
fs.deleteDirectory(path.join(angularTemplatePath, "node_modules")).wait();
184+
fs.deleteDirectory(path.join(angularTemplatePath, "node_modules"));
185185

186186
let typescriptTemplateDir = temp.mkdirSync("typescriptTemplate");
187187
fs.writeJson(path.join(typescriptTemplateDir, "package.json"), {
@@ -194,7 +194,7 @@ describe("Project Service Tests", () => {
194194
}).wait();
195195
npmInstallationManager.install("tns-template-hello-world-ts", typescriptTemplateDir, {dependencyType: "save"}).wait();
196196
typescriptTemplatePath = path.join(typescriptTemplateDir, "node_modules", "tns-template-hello-world-ts");
197-
fs.deleteDirectory(path.join(typescriptTemplatePath, "node_modules")).wait();
197+
fs.deleteDirectory(path.join(typescriptTemplatePath, "node_modules"));
198198
});
199199

200200
it("creates valid project from default template", () => {

test/project-templates-service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ function createTestInjector(configuration?: {shouldNpmInstallThrow: boolean, npm
2525
if(directory.indexOf("node_modules") !== -1) {
2626
isDeleteDirectoryCalledForNodeModulesDir = true;
2727
}
28-
return Future.fromResult();
2928
}
3029

3130
});

0 commit comments

Comments
 (0)