Skip to content

Commit e063be9

Browse files
committed
fix: ENOENT reading from non existent nativescript.config.js
1 parent d1729cf commit e063be9

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

lib/definitions/project.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ interface IProjectConfigService {
308308
* @param key the property key path
309309
* @param value
310310
*/
311-
setValue(key: string, value: SupportedConfigValues): any;
311+
setValue(key: string, value: SupportedConfigValues): Promise<boolean>;
312312

313313
detectInfo(
314314
projectDir?: string

lib/project-data.ts

+14-16
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,19 @@ export class ProjectData implements IProjectData {
142142
const projectFilePath = this.getProjectFilePath(projectDir);
143143
// If no project found, projectDir should be null
144144
// handle migration cases
145-
let isMigrate = false;
146-
if (
147-
this.$options.argv &&
148-
this.$options.argv._ &&
149-
this.$options.argv._.length
150-
) {
151-
this.$logger.debug(
152-
"the value of this.$options.argv._[0] is: " + this.$options.argv._[0]
153-
);
154-
isMigrate = this.$options.argv._[0] === "migrate";
155-
}
156-
this.$logger.debug(`'initializingProjectData, isMigrate is ${isMigrate}.`);
157-
const nsConfig: INsConfig = isMigrate
158-
? null
159-
: this.projectConfig.readConfig(projectDir);
145+
// let isMigrate = false;
146+
// if (
147+
// this.$options.argv &&
148+
// this.$options.argv._ &&
149+
// this.$options.argv._.length
150+
// ) {
151+
// this.$logger.debug(
152+
// "the value of this.$options.argv._[0] is: " + this.$options.argv._[0]
153+
// );
154+
// isMigrate = this.$options.argv._[0] === "migrate";
155+
// }
156+
// this.$logger.debug(`'initializingProjectData, isMigrate is ${isMigrate}.`);
157+
const nsConfig: INsConfig = this.projectConfig.readConfig(projectDir);
160158
let packageJsonData = null;
161159

162160
try {
@@ -169,7 +167,7 @@ export class ProjectData implements IProjectData {
169167
);
170168
}
171169

172-
if ((isMigrate || nsConfig) && packageJsonData) {
170+
if (packageJsonData) {
173171
this.projectDir = projectDir;
174172
this.projectName = this.$projectHelper.sanitizeName(
175173
path.basename(projectDir)

lib/services/project-config-service.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export default {
125125
public readConfig(projectDir?: string): INsConfig {
126126
const {
127127
hasTS,
128+
hasJS,
128129
configJSFilePath,
129130
configTSFilePath,
130131
usesLegacyConfig,
@@ -134,6 +135,9 @@ export default {
134135
let config: INsConfig;
135136

136137
if (usesLegacyConfig) {
138+
this.$logger.trace(
139+
"Project Config Service: Using legacy nsconfig.json..."
140+
);
137141
return this._readAndUpdateLegacyConfig(configNSConfigFilePath);
138142
}
139143

@@ -149,7 +153,7 @@ export default {
149153
config = result["default"] ? result["default"] : result;
150154
// console.log('transpiledSource.outputText:', transpiledSource.outputText)
151155
// config = eval(transpiledSource.outputText);
152-
} else {
156+
} else if (hasJS) {
153157
const rawSource = this.$fs.readText(configJSFilePath);
154158
// console.log('rawSource:', rawSource)
155159
// config = eval(rawSource);

0 commit comments

Comments
 (0)