Skip to content
Permalink
Browse files

feat(core): allow no config to be present, default to an empty object (

  • Loading branch information
MarshallOfSound committed Jul 27, 2018
1 parent a5bec3a commit c71ef16354f82cb2f4f5db93c4762011e2c66594
Showing with 15 additions and 3 deletions.
  1. +1 −1 packages/api/core/src/util/forge-config.ts
  2. +14 −2 packages/api/core/src/util/resolve-dir.ts
@@ -71,7 +71,7 @@ export function fromBuildIdentifier<T>(map: { [key: string]: T | undefined }) {

export default async (dir: string) => {
const packageJSON = await readRawPackageJson(dir);
let forgeConfig: ForgeConfig | string = packageJSON.config.forge;
let forgeConfig: ForgeConfig | string = (packageJSON.config && packageJSON.config.forge) ? packageJSON.config.forge : {};

if (typeof forgeConfig === 'string' && (await fs.pathExists(path.resolve(dir, forgeConfig)) || await fs.pathExists(path.resolve(dir, `${forgeConfig}.js`)))) {
try {
@@ -11,6 +11,9 @@ const d = debug('electron-forge:project-resolver');
// the dir without calling getElectronVersion
export default async (dir: string) => {
let mDir = dir;
let bestGuessDir: string | null = null;
let lastError: string | null = null;

let prevDir;
while (prevDir !== mDir) {
prevDir = mDir;
@@ -24,18 +27,27 @@ export default async (dir: string) => {
const electronVersion = getElectronVersion(packageJSON);
if (electronVersion) {
if (!/[0-9]/.test(electronVersion[0])) {
throw `You must depend on an EXACT version of electron not a range (${electronVersion})`;
lastError = `You must depend on an EXACT version of electron not a range (${electronVersion})`;
}
} else {
throw 'You must depend on "electron" in your devDependencies';
lastError = 'You must depend on "electron" in your devDependencies';
}

if (packageJSON.config && packageJSON.config.forge) {
d('electron-forge compatible package.json found in', testPath);
return mDir;
}

bestGuessDir = mDir;
}
mDir = path.dirname(mDir);
}
if (bestGuessDir) {
d('guessing on the best electron-forge package.json found in', bestGuessDir);
return bestGuessDir;
}
if (lastError) {
throw lastError;
}
return null;
};

0 comments on commit c71ef16

Please sign in to comment.
You can’t perform that action at this time.