diff --git a/.gitignore b/.gitignore index 589ccd49b..0b374ddde 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ /build/ /dist/ /external_binaries/ -/node_modules +node_modules /out/ /vendor/.gclient /vendor/debian_jessie_amd64-sysroot/ diff --git a/npm/test/index.js b/npm/test/index.js index 302a650a4..944feb028 100644 --- a/npm/test/index.js +++ b/npm/test/index.js @@ -4,8 +4,6 @@ const path = require('path') const sinon = require('sinon') const admZip = require('adm-zip') const temp = require('temp') -// var pathExists = require('path-exists') -// var getHomePath = require('home-path')() let sandbox const mockEnv = { @@ -22,7 +20,6 @@ temp.track() tape('set up', (t) => { sandbox = sinon.sandbox.create() tempDir = temp.mkdirSync('electron-install') - console.log(tempDir) t.end() }) diff --git a/script/publish-to-npm.js b/script/publish-to-npm.js index 5066a9fff..2a06cfb31 100644 --- a/script/publish-to-npm.js +++ b/script/publish-to-npm.js @@ -7,7 +7,8 @@ const temp = require('temp'), childProcess = require('child_process'), GitHubApi = require('github'), request = require('request'), - rootPackageJson = require('../package.json') + rootPackageJson = require('../package.json'), + assert = require('assert') const github = new GitHubApi({ // debug: true, @@ -48,9 +49,9 @@ new Promise((resolve, reject) => { resolve(dirPath) } }) -}).then((dirPath) => { +}) +.then((dirPath) => { tempDir = dirPath - // copy files from `/npm` to temp directory files.forEach((name) => { fs.writeFileSync( @@ -72,22 +73,21 @@ new Promise((resolve, reject) => { owner: 'electron', repo: 'electron', }) - -}).then((releases) => { +}) +.then((releases) => { // download electron.d.ts from draft release const draftRelease = releases.data.find( - // (release) => release.draft && release.tag_name === `v${rootPackageJson.version}` - (release) => release.draft && release.tag_name === `test` - + (release) => release.draft && release.tag_name === `v${rootPackageJson.version}` + // (release) => release.draft && release.tag_name === `test` ) if (!draftRelease) { throw `cannot find release with tag v${rootPackageJson.version}` } return draftRelease.assets.find((asset) => asset.name === 'electron.d.ts') - -}).then((tsdAsset) => { +}) +.then((tsdAsset) => { if (!tsdAsset) { - throw 'cannot find electron.d.ts from draft release assets' + throw `cannot find electron.d.ts from v${rootPackageJson.version} draft release assets` } return new Promise((resolve, reject) => { request.get({ @@ -107,5 +107,22 @@ new Promise((resolve, reject) => { }) }) }) -.then(() => childProcess.execSync('npm publish', { cwd: tempDir })) +.then(() => childProcess.execSync('npm pack', { cwd: tempDir })) +.then(() => { + // test that the package can install electron prebuilt from /dist + const distDir = path.join(__dirname, '..', 'dist') + const tarballPath = path.join(tempDir, `electron-${rootPackageJson.version}.tgz`) + return new Promise((resolve, reject) => { + childProcess.execSync(`npm install ${tarballPath} --force --silent`, { + env: Object.assign({}, process.env, { electron_config_cache: distDir }), + cwd: tempDir, + }) + const checkVersion = childProcess.exec(`${path.join(tempDir, 'node_modules', '.bin', 'electron')} -v`) + checkVersion.stdout.on('data', (data) => { + assert.strictEqual(data.trim(), `v${rootPackageJson.version}`) + resolve(tarballPath) + }) + }) +}) +.then((tarballPath) => childProcess.execSync(`npm publish ${tarballPath}`)) .catch((err) => console.error(`Error: ${err}`))