File tree 3 files changed +25
-4
lines changed
3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ interface INsConfig {
161
161
visionos ?: INSConfigVisionOS ;
162
162
ignoredNativeDependencies ?: string [ ] ;
163
163
hooks ?: INsConfigHooks [ ] ;
164
+ projectName ?: string ;
164
165
}
165
166
166
167
interface IProjectData extends ICreateProjectData {
@@ -195,6 +196,7 @@ interface IProjectData extends ICreateProjectData {
195
196
* The value can be changed by setting `webpackConfigPath` in nativescript.config.
196
197
*/
197
198
webpackConfigPath : string ;
199
+ projectName : string ;
198
200
199
201
/**
200
202
* Initializes project data with the given project directory. If none supplied defaults to --path option or cwd.
Original file line number Diff line number Diff line change @@ -162,9 +162,10 @@ export class ProjectData implements IProjectData {
162
162
}
163
163
164
164
if ( packageJsonData ) {
165
- this . projectName = this . $projectHelper . sanitizeName (
166
- path . basename ( projectDir )
167
- ) ;
165
+ this . projectName =
166
+ nsConfig && nsConfig . projectName
167
+ ? nsConfig . projectName
168
+ : this . $projectHelper . sanitizeName ( path . basename ( projectDir ) ) ;
168
169
this . platformsDir = path . join ( projectDir , constants . PLATFORMS_DIR_NAME ) ;
169
170
this . projectFilePath = projectFilePath ;
170
171
this . projectIdentifiers = this . initializeProjectIdentifiers ( nsConfig ) ;
Original file line number Diff line number Diff line change @@ -53,7 +53,11 @@ describe("projectData", () => {
53
53
dependencies ?: IStringDictionary ;
54
54
devDependencies : IStringDictionary ;
55
55
} ;
56
- configData ?: { shared ?: boolean ; webpackConfigPath ?: string } ;
56
+ configData ?: {
57
+ shared ?: boolean ;
58
+ webpackConfigPath ?: string ;
59
+ projectName ?: string ;
60
+ } ;
57
61
} ) : IProjectData => {
58
62
const testInjector = createTestInjector ( ) ;
59
63
const fs = testInjector . resolve ( "fs" ) ;
@@ -172,6 +176,20 @@ describe("projectData", () => {
172
176
} ) ;
173
177
} ) ;
174
178
179
+ describe ( "projectName" , ( ) => {
180
+ it ( "has correct name when no value is set in nativescript.conf" , ( ) => {
181
+ const projectData = prepareTest ( ) ;
182
+ assert . isString ( "projectDir" , projectData . projectName ) ;
183
+ } ) ;
184
+
185
+ it ( "has correct name when a project name is set in nativescript.conf" , ( ) => {
186
+ const projectData = prepareTest ( {
187
+ configData : { projectName : "specifiedProjectName" } ,
188
+ } ) ;
189
+ assert . isString ( "specifiedProjectName" , projectData . projectName ) ;
190
+ } ) ;
191
+ } ) ;
192
+
175
193
describe ( "webpackConfigPath" , ( ) => {
176
194
it ( "default path to webpack.config.js is set when nsconfig.json does not set value" , ( ) => {
177
195
const projectData = prepareTest ( ) ;
You can’t perform that action at this time.
0 commit comments