Skip to content

Commit

Permalink
fix: ENOENT reading from non existent nativescript.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
rigor789 committed Sep 4, 2020
1 parent d1729cf commit e063be9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ interface IProjectConfigService {
* @param key the property key path
* @param value
*/
setValue(key: string, value: SupportedConfigValues): any;
setValue(key: string, value: SupportedConfigValues): Promise<boolean>;

detectInfo(
projectDir?: string
Expand Down
30 changes: 14 additions & 16 deletions lib/project-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,19 @@ export class ProjectData implements IProjectData {
const projectFilePath = this.getProjectFilePath(projectDir);
// If no project found, projectDir should be null
// handle migration cases
let isMigrate = false;
if (
this.$options.argv &&
this.$options.argv._ &&
this.$options.argv._.length
) {
this.$logger.debug(
"the value of this.$options.argv._[0] is: " + this.$options.argv._[0]
);
isMigrate = this.$options.argv._[0] === "migrate";
}
this.$logger.debug(`'initializingProjectData, isMigrate is ${isMigrate}.`);
const nsConfig: INsConfig = isMigrate
? null
: this.projectConfig.readConfig(projectDir);
// let isMigrate = false;
// if (
// this.$options.argv &&
// this.$options.argv._ &&
// this.$options.argv._.length
// ) {
// this.$logger.debug(
// "the value of this.$options.argv._[0] is: " + this.$options.argv._[0]
// );
// isMigrate = this.$options.argv._[0] === "migrate";
// }
// this.$logger.debug(`'initializingProjectData, isMigrate is ${isMigrate}.`);
const nsConfig: INsConfig = this.projectConfig.readConfig(projectDir);
let packageJsonData = null;

try {
Expand All @@ -169,7 +167,7 @@ export class ProjectData implements IProjectData {
);
}

if ((isMigrate || nsConfig) && packageJsonData) {
if (packageJsonData) {
this.projectDir = projectDir;
this.projectName = this.$projectHelper.sanitizeName(
path.basename(projectDir)
Expand Down
6 changes: 5 additions & 1 deletion lib/services/project-config-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default {
public readConfig(projectDir?: string): INsConfig {
const {
hasTS,
hasJS,
configJSFilePath,
configTSFilePath,
usesLegacyConfig,
Expand All @@ -134,6 +135,9 @@ export default {
let config: INsConfig;

if (usesLegacyConfig) {
this.$logger.trace(
"Project Config Service: Using legacy nsconfig.json..."
);
return this._readAndUpdateLegacyConfig(configNSConfigFilePath);
}

Expand All @@ -149,7 +153,7 @@ export default {
config = result["default"] ? result["default"] : result;
// console.log('transpiledSource.outputText:', transpiledSource.outputText)
// config = eval(transpiledSource.outputText);
} else {
} else if (hasJS) {
const rawSource = this.$fs.readText(configJSFilePath);
// console.log('rawSource:', rawSource)
// config = eval(rawSource);
Expand Down

0 comments on commit e063be9

Please sign in to comment.