diff --git a/.editorconfig b/.editorconfig index 31e4ce20855..67ed8eabbef 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,10 +4,8 @@ # For all files in this project: # - 2-space soft tabs -# - All files end with a line-break # - Trim trailing whitespace [*] indent_style = space indent_size = 2 -insert_final_newline = true trim_trailing_whitespace = true diff --git a/.travis.yml b/.travis.yml index c6b9679499d..b7a6d43ba21 100755 --- a/.travis.yml +++ b/.travis.yml @@ -32,8 +32,9 @@ before_install: install: - nvm install $NODE_VERSION -- if [[ "$TRAVIS_OS_NAME" == "osx" && "$NODE_VERSION" == "4" ]]; then npm install npm -g ; fi -- if [[ "$TRAVIS_OS_NAME" == "osx" || "$NODE_VERSION" == "6" ]]; then npm install && npm prune ; fi +- if [[ "$NODE_VERSION" == "4" ]]; then npm install npm -g ; fi +- npm install +- npm prune script: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then npm run test ; fi @@ -41,7 +42,7 @@ script: after_success: - node out/cleanup.js -- if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" && "$AUTO_PUBLISH" != "false" && "$NODE_VERSION" == "6" ]]; then npm run semantic-release ; fi +- if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" && "$AUTO_PUBLISH" != "false" ]]; then npm run semantic-release ; fi branches: except: diff --git a/appveyor.yml b/appveyor.yml index d0765bc8416..c582010bf51 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,10 +9,8 @@ cache: install: - ps: Install-Product node 6 x64 - npm install npm -g - - node -v - - npm -v - - npm prune - npm install + - npm prune build: off diff --git a/src/util.ts b/src/util.ts index 2526d448e16..d601633da19 100644 --- a/src/util.ts +++ b/src/util.ts @@ -124,6 +124,11 @@ export function handleProcess(event: string, childProcess: ChildProcess, command } export async function getElectronVersion(packageData: any, packageJsonPath: string): Promise { + const build = packageData.build + // build is required, but this check is performed later, so, we should check for null + if (build != null && build.electronVersion != null) { + return build.electronVersion + } try { return (await readJson(path.join(path.dirname(packageJsonPath), "node_modules", "electron-prebuilt", "package.json"))).version } @@ -133,13 +138,7 @@ export async function getElectronVersion(packageData: any, packageJsonPath: stri } } - const devDependencies = packageData.devDependencies - let electronPrebuiltDep = devDependencies == null ? null : devDependencies["electron-prebuilt"] - if (electronPrebuiltDep == null) { - const dependencies = packageData.dependencies - electronPrebuiltDep = dependencies == null ? null : dependencies["electron-prebuilt"] - } - + const electronPrebuiltDep = findFromElectronPrebuilt(packageData) if (electronPrebuiltDep == null) { throw new Error("Cannot find electron-prebuilt dependency to get electron version in the '" + packageJsonPath + "'") } @@ -148,6 +147,21 @@ export async function getElectronVersion(packageData: any, packageJsonPath: stri return firstChar === "^" || firstChar === "~" ? electronPrebuiltDep.substring(1) : electronPrebuiltDep } +function findFromElectronPrebuilt(packageData: any): any { + for (let name of ["electron-prebuilt", "electron-prebuilt-compile"]) { + const devDependencies = packageData.devDependencies + let electronPrebuiltDep = devDependencies == null ? null : devDependencies[name] + if (electronPrebuiltDep == null) { + const dependencies = packageData.dependencies + electronPrebuiltDep = dependencies == null ? null : dependencies[name] + } + if (electronPrebuiltDep != null) { + return electronPrebuiltDep + } + } + return null +} + export async function statOrNull(file: string): Promise { try { return await stat(file) diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index 5e357b6eaa9..e1b14a7e0c8 100755 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -101,10 +101,15 @@ test("relative index", () => assertPack("test-app", allPlatforms(false), { }, true) })) -test("version from electron-prebuilt dependency", () => assertPack("test-app-one", currentPlatform(false), { +const electronVersion = "0.37.8" + +test("electron version from electron-prebuilt dependency", () => assertPack("test-app-one", { + platform: [Platform.LINUX], + dist: false, +}, { tempDirCreated: projectDir => BluebirdPromise.all([ outputJson(path.join(projectDir, "node_modules", "electron-prebuilt", "package.json"), { - version: "0.37.8" + version: electronVersion }), modifyPackageJson(projectDir, data => { data.devDependencies = {} @@ -112,6 +117,16 @@ test("version from electron-prebuilt dependency", () => assertPack("test-app-one ]) })) +test("electron version from build", () => assertPack("test-app-one", { + platform: [Platform.LINUX], + dist: false, +}, { + tempDirCreated: projectDir => modifyPackageJson(projectDir, data => { + data.devDependencies = {} + data.build.electronVersion = electronVersion + }) +})) + test("www as default dir", () => assertPack("test-app", currentPlatform(), { tempDirCreated: projectDir => move(path.join(projectDir, "app"), path.join(projectDir, "www")) }))