Skip to content

Commit b842e9e

Browse files
tzraikovrosen-vladimirov
authored andcommitted
Fixed: tns update crashes with error message (#2421)
1 parent 68e7515 commit b842e9e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/commands/update.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export class UpdateCommand implements ICommand {
99
private $platformsData: IPlatformsData,
1010
private $pluginsService: IPluginsService,
1111
private $projectDataService: IProjectDataService,
12+
private $fs: IFileSystem,
1213
private $logger: ILogger) { }
1314

1415
public async execute(args: string[]): Promise<void> {
@@ -20,7 +21,10 @@ export class UpdateCommand implements ICommand {
2021
shelljs.mkdir(tmpDir);
2122
shelljs.cp(path.join(this.$projectData.projectDir, "package.json"), tmpDir);
2223
for (let folder of folders) {
23-
shelljs.cp("-rf", path.join(this.$projectData.projectDir, folder), tmpDir);
24+
let folderToCopy = path.join(this.$projectData.projectDir, folder);
25+
if (this.$fs.exists(folderToCopy)) {
26+
shelljs.cp("-rf", folderToCopy, tmpDir);
27+
}
2428
}
2529
} catch (error) {
2630
this.$logger.error("Could not backup project folders!");
@@ -33,7 +37,12 @@ export class UpdateCommand implements ICommand {
3337
shelljs.cp("-f", path.join(tmpDir, "package.json"), this.$projectData.projectDir);
3438
for (let folder of folders) {
3539
shelljs.rm("-rf", path.join(this.$projectData.projectDir, folder));
36-
shelljs.cp("-fr", path.join(tmpDir, folder), this.$projectData.projectDir);
40+
41+
let folderToCopy = path.join(tmpDir, folder);
42+
43+
if (this.$fs.exists(folderToCopy)) {
44+
shelljs.cp("-fr", folderToCopy, this.$projectData.projectDir);
45+
}
3746
}
3847

3948
this.$logger.error("Could not update the project!");

0 commit comments

Comments
 (0)