Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Aug 11, 2016
1 parent ee2f7c8 commit 73171c9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ platform:
- x64

cache:
- node_modules
- '%USERPROFILE%\.electron'
- '%USERPROFILE%\.cache\nsis'

install:
- ps: Install-Product node 6 x64
Expand Down
2 changes: 1 addition & 1 deletion src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export default class NsisTarget extends Target {
// we use NSIS_CONFIG_CONST_DATA_PATH=no to build makensis on Linux, but in any case it doesn't use stubs as MacOS/Windows version, so, we explicitly set NSISDIR
env: Object.assign({}, process.env, {NSISDIR: nsisPath}),
cwd: nsisTemplatesDir,
})
}, true)
handleProcess("close", childProcess, command, resolve, reject)

childProcess.stdin.end(script)
Expand Down
6 changes: 3 additions & 3 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function installDependencies(appDir: string, electronVersion: string, arc

export function spawnNpmProduction(command: string, appDir: string, env?: any): BluebirdPromise<any> {
let npmExecPath = process.env.npm_execpath || process.env.NPM_CLI_JS
const npmExecArgs = [command, "--production"]
const npmExecArgs = [command, "--production", "--cache-min", "999999999"]
if (npmExecPath == null) {
npmExecPath = process.platform === "win32" ? "npm.cmd" : "npm"
}
Expand Down Expand Up @@ -96,12 +96,12 @@ export function exec(file: string, args?: Array<string> | null, options?: ExecOp
})
}

export function doSpawn(command: string, args: Array<string>, options?: SpawnOptions): ChildProcess {
export function doSpawn(command: string, args: Array<string>, options?: SpawnOptions, pipeInput?: Boolean): ChildProcess {
if (options == null) {
options = {}
}
if (options.stdio == null) {
options.stdio = ["pipe", debug.enabled ? "inherit" : "pipe", "pipe"]
options.stdio = [pipeInput ? "pipe" : "ignore", debug.enabled ? "inherit" : "pipe", "pipe"]
}

if (debug.enabled) {
Expand Down
29 changes: 24 additions & 5 deletions test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,11 @@ test.ifDevOrLinuxCi("extra metadata", () => {
}),
packed: projectDir => {
assertThat(JSON.parse(extractFile(path.join(projectDir, "dist", "linux", "resources", "app.asar"), "package.json").toString())).hasProperties({
foo: {
bar: 12,
existingProp: 22,
}
foo: {
bar: 12,
existingProp: 22,
}
)
})
return BluebirdPromise.resolve()
}
})
Expand All @@ -256,6 +255,26 @@ test.ifOsx("app-executable-deps", () => {
})
})

test.ifDevOrLinuxCi("smart unpack", () => {
return assertPack("test-app-one", {
targets: Platform.LINUX.createTarget(DIR_TARGET),
}, {
npmInstallBefore: true,
tempDirCreated: projectDir => modifyPackageJson(projectDir, data => {
data.dependencies = {
"debug": "^2.2.0",
"edge-cs": "^1.0.0"
}
}),
packed: projectDir => {
assertThat(JSON.parse(extractFile(path.join(projectDir, "dist", "linux", "resources", "app.asar"), "node_modules/debug/package.json").toString())).hasProperties({
name: "debug"
})
return BluebirdPromise.resolve()
}
})
})

test.ifWinCi("Build MacOS on Windows is not supported", (t: any) => t.throws(assertPack("test-app-one", platform(Platform.MAC)), /Build for MacOS is supported only on MacOS.+/))

function allPlatforms(dist: boolean = true): PackagerOptions {
Expand Down
6 changes: 6 additions & 0 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getArchSuffix, Target } from "out/platformPackager"
import pathSorter = require("path-sort")
import DecompressZip = require("decompress-zip")
import { convertVersion } from "electron-winstaller-fixed"
import { spawnNpmProduction } from "out/util/util"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("out/util/awaiter")
Expand All @@ -33,6 +34,8 @@ interface AssertPackOptions {
readonly expectedDepends?: string

readonly useTempDir?: boolean

readonly npmInstallBefore?: boolean
}

export async function assertPack(fixtureName: string, packagerOptions: PackagerOptions, checkOptions?: AssertPackOptions): Promise<void> {
Expand Down Expand Up @@ -61,6 +64,9 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO
try {
if (tempDirCreated != null) {
await tempDirCreated(projectDir)
if (checkOptions != null && checkOptions.npmInstallBefore) {
await spawnNpmProduction("install", projectDir)
}
}

await packAndCheck(projectDir, Object.assign({
Expand Down

0 comments on commit 73171c9

Please sign in to comment.