Skip to content

Commit 34067fe

Browse files
committed
Fix coding style. Add optional parameter tnsModulesVersion.
1 parent f768c15 commit 34067fe

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

lib/declarations.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface INodePackageManager {
66
cache(packageName: string, version: string, cache?: any): IFuture<IDependencyData>;
77
cacheUnpack(packageName: string, version: string, unpackTarget?: string): IFuture<void>;
88
view(packageName: string, propertyName: string): IFuture<any>;
9-
executeNpmCommand(npmCommandName: string, currentWorkingDirectory: string): IFuture<void>;
9+
executeNpmCommand(npmCommandName: string, currentWorkingDirectory: string): IFuture<any>;
1010
}
1111

1212
interface INpmInstallationManager {
@@ -79,6 +79,7 @@ interface IOptions extends ICommonOptions {
7979
keyStoreAliasPassword: string;
8080
sdk: string;
8181
ignoreScripts: boolean;
82+
tnsModulesVersion: string;
8283
}
8384

8485
interface IProjectFilesManager {

lib/node-package-manager.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ export class NodePackageManager implements INodePackageManager {
5555
return this.loadAndExecute("view", [[packageName, propertyName], [false]]);
5656
}
5757

58-
public executeNpmCommand(npmCommandName: string, currentWorkingDirectory: string): IFuture<void> {
58+
public executeNpmCommand(npmCommandName: string, currentWorkingDirectory: string): IFuture<any> {
5959
return (() => {
60-
this.$childProcess.exec(npmCommandName, { cwd: currentWorkingDirectory }).wait();
61-
}).future<void>()();
60+
return this.$childProcess.exec(npmCommandName, { cwd: currentWorkingDirectory }).wait();
61+
}).future<any>()();
6262
}
6363

6464
private loadAndExecute(commandName: string, args: any[], opts?: { config?: any, subCommandName?: string }): IFuture<any> {

lib/options.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export class Options extends commonOptionsLibPath.OptionsBase {
2727
keyStoreAlias: { type: OptionType.String },
2828
keyStoreAliasPassword: { type: OptionType.String },
2929
sdk: { type: OptionType.String },
30-
ignoreScripts: {type: OptionType.Boolean }
30+
ignoreScripts: {type: OptionType.Boolean },
31+
tnsModulesVersion: { type: OptionType.String }
3132
},
3233
path.join($hostInfo.isWindows ? process.env.LocalAppData : path.join(osenv.home(), ".local/share"), ".nativescript-cli"),
3334
$errors, $staticConfig);

lib/services/project-service.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,14 @@ export class ProjectService implements IProjectService {
112112

113113
this.$projectDataService.initialize(projectDir);
114114
this.$projectDataService.setValue("id", projectId).wait();
115-
this.$npm.executeNpmCommand("npm install " + constants.TNS_CORE_MODULES_NAME + " --save --save-exact", projectDir).wait();
115+
116+
let tnsModulesVersion: string = this.$options.tnsModulesVersion;
117+
let packageName: string = constants.TNS_CORE_MODULES_NAME;
118+
if (tnsModulesVersion) {
119+
packageName = packageName.concat("@" + tnsModulesVersion);
120+
}
121+
122+
this.$npm.executeNpmCommand("npm install " + packageName + " --save --save-exact", projectDir).wait();
116123
}).future<void>()();
117124
}
118125

lib/tools/broccoli/node-modules-dest-copy.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ export class DestCopy implements IBroccoliPlugin {
7676
this.$pluginsService.prepare(dependency).wait();
7777
}
7878

79-
if (dependency.name == constants.TNS_CORE_MODULES_NAME) {
80-
shelljs.cp("-Rf", path.join(this.outputRoot, constants.TNS_CORE_MODULES_NAME, "*"), this.outputRoot);
81-
this.$fs.deleteDirectory(path.join(this.outputRoot, constants.TNS_CORE_MODULES_NAME)).wait();
79+
if (dependency.name === constants.TNS_CORE_MODULES_NAME) {
80+
let tnsCoreModulesResourcePath = path.join(this.outputRoot, constants.TNS_CORE_MODULES_NAME);
81+
shelljs.cp("-Rf", path.join(tnsCoreModulesResourcePath, "*"), this.outputRoot);
82+
this.$fs.deleteDirectory(tnsCoreModulesResourcePath).wait();
8283
}
8384
});
8485
}

0 commit comments

Comments
 (0)