Skip to content

Commit

Permalink
feat: add node-gyp-rebuild #683
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Aug 22, 2016
1 parent 92d4895 commit e3a5899
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"bin": {
"build": "./out/build-cli.js",
"cleanup": "./out/cleanup.js",
"install-app-deps": "./out/install-app-deps.js"
"install-app-deps": "./out/install-app-deps.js",
"node-gyp-rebuild": "./out/node-gyp-rebuild.js"
},
"scripts": {
"compile": "npm run compile-production && npm run compile-test && npm run compile-updater",
Expand Down
34 changes: 34 additions & 0 deletions src/node-gyp-rebuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/env node

import { getElectronVersion, exec, getGypEnv } from "./util/util"
import { printErrorAndExit } from "./util/promise"
import * as path from "path"
import yargs = require("yargs")
import { readPackageJson } from "./util/readPackageJson"
import { log } from "./util/log"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./util/awaiter")

const args: any = yargs
.option("arch", {
choices: ["ia32", "x64"],
}).argv

const projectDir = process.cwd()
const devPackageFile = path.join(projectDir, "package.json")

async function main() {
const arch = args.arch || process.arch
log(`Execute node-gyp rebuild for arch ${arch}`)
await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
env: getGypEnv(await getElectronVersion(await readPackageJson(devPackageFile), devPackageFile), arch),
})
}

try {
main()
}
catch (e) {
printErrorAndExit(e)
}
2 changes: 1 addition & 1 deletion src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class Packager implements BuildInfo {

private async installAppDependencies(platform: Platform, arch: Arch): Promise<any> {
if (this.devMetadata.build.nodeGypRebuild === true) {
log("Execute node-gyp rebuild")
log(`Execute node-gyp rebuild for arch ${Arch[arch]}`)
await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
env: getGypEnv(this.electronVersion, Arch[arch]),
})
Expand Down
7 changes: 7 additions & 0 deletions src/publish/gitHubPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,11 @@ export class GitHubPublisher implements Publisher {

warn(`Cannot delete release ${release.id}`)
}

// async deleteOldReleases() {
// const releases = await githubRequest<Array<Release>>(`/repos/${this.owner}/${this.repo}/releases`, this.token)
// for (let release of releases) {
// await githubRequest(`/repos/${this.owner}/${this.repo}/releases/${release.id}`, this.token, null, "DELETE")
// }
// }
}
2 changes: 2 additions & 0 deletions test/src/ArtifactPublisherTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ testAndIgnoreApiRate("incorrect tag name", async () => {
prerelease: true,
publish: "onTagOrDraft",
})

// await publisher.deleteOldReleases()
try {
await publisher.releasePromise
//noinspection ExceptionCaughtLocallyJS
Expand Down

0 comments on commit e3a5899

Please sign in to comment.