From 5c02cb4ce2600eab9cc387f680561b77160aaa91 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Tue, 2 Oct 2018 19:18:15 -0700 Subject: [PATCH 1/3] Drop Node 4, test Node 10, upgrade ESLint --- .travis.yml | 2 +- package.json | 12 ++++++------ src/installer.js | 6 +++--- test/helpers/dependencies.js | 2 +- test/helpers/describe_installer.js | 4 ++-- test/installer.js | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 672fd3c..e8f9829 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: node_js node_js: + - '10' - '8' - '6' - - '4' env: - DEBUG="electron-installer-debian" diff --git a/package.json b/package.json index 47c0766..2325a71 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "test": "npm run lint && npm run spec" }, "engines": { - "node": ">=4.0.0" + "node": ">=6.0.0" }, "dependencies": { "asar": "^0.14.0", @@ -49,12 +49,12 @@ }, "devDependencies": { "chai": "^4.1.2", - "eslint": "^4.9.0", - "eslint-config-standard": "^11.0.0", + "eslint": "^5.6.1", + "eslint-config-standard": "^12.0.0", "eslint-plugin-import": "^2.7.0", - "eslint-plugin-node": "^6.0.1", - "eslint-plugin-promise": "^3.6.0", - "eslint-plugin-standard": "^3.0.1", + "eslint-plugin-node": "^7.0.1", + "eslint-plugin-promise": "^4.0.1", + "eslint-plugin-standard": "^4.0.0", "mocha": "^5.0.5", "mz": "^2.7.0", "nyc": "^11.4.1", diff --git a/src/installer.js b/src/installer.js index 456688e..03bf110 100644 --- a/src/installer.js +++ b/src/installer.js @@ -84,7 +84,7 @@ function transformVersion (version) { * read from `package.json`, and some are hardcoded. */ function getDefaults (data) { - const src = {src: data.src} + const src = { src: data.src } return Promise.all([readMeta(data), getSize(src), dependencies.getElectronVersion(src)]) .then(results => { const pkg = results[0] || {} @@ -171,7 +171,7 @@ function getOptions (data, defaults) { .replace(/\r\n/g, '\n') // Fixes errors when finding blank lines in Windows .replace(/^$/mg, '.') .split('\n') - .map(line => wrap(line, {width: 80, indent: ' '})) + .map(line => wrap(line, { width: 80, indent: ' ' })) .join('\n') } @@ -411,7 +411,7 @@ function movePackage (options, dir) { const template = options.rename(options.dest, path.basename(file)) const dest = _.template(template)(options) options.logger(`Moving file ${file} to ${dest}`) - return fs.move(file, dest, {clobber: true}) + return fs.move(file, dest, { clobber: true }) }))).catch(wrapError('moving package files')) } diff --git a/test/helpers/dependencies.js b/test/helpers/dependencies.js index 2819ceb..4db7ce8 100644 --- a/test/helpers/dependencies.js +++ b/test/helpers/dependencies.js @@ -1,7 +1,7 @@ 'use strict' const _ = require('lodash') -const exec = require('mz/child_process').exec +const { exec } = require('mz/child_process') const dependencies = require('../../src/dependencies') diff --git a/test/helpers/describe_installer.js b/test/helpers/describe_installer.js index 63cf2c9..c4209b2 100644 --- a/test/helpers/describe_installer.js +++ b/test/helpers/describe_installer.js @@ -26,7 +26,7 @@ module.exports.cleanupOutputDir = function cleanupOutputDir (outputDir) { } module.exports.tempOutputDir = function tempOutputDir (customDir) { - return customDir ? path.join(os.tmpdir(), customDir) : temp.path({prefix: 'electron-installer-debian-'}) + return customDir ? path.join(os.tmpdir(), customDir) : temp.path({ prefix: 'electron-installer-debian-' }) } module.exports.testInstallerOptions = function testInstallerOptions (outputDir, installerOptions) { @@ -37,5 +37,5 @@ module.exports.testInstallerOptions = function testInstallerOptions (outputDir, options: { arch: 'amd64' } - }, installerOptions, {dest: outputDir}) + }, installerOptions, { dest: outputDir }) } diff --git a/test/installer.js b/test/installer.js index ee808b3..d20d355 100644 --- a/test/installer.js +++ b/test/installer.js @@ -1,7 +1,7 @@ 'use strict' const chai = require('chai') -const exec = require('mz/child_process').exec +const { exec } = require('mz/child_process') const fs = require('fs-extra') const path = require('path') @@ -123,7 +123,7 @@ describe('module', function () { .then(() => exec('dpkg-deb -x bartest_amd64.deb .', { cwd: outputDir })) .then(() => fs.readFile(path.join(outputDir, 'usr/share/applications/bartest.desktop'))) .then(data => { - if (data.toString().indexOf('Comment=Hardcoded comment') === -1) { + if (!data.toString().includes('Comment=Hardcoded comment')) { throw new Error('Did not use custom template') } return Promise.resolve() From 37a760ac974500a019dd13980e972c3bc9c834fd Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Tue, 2 Oct 2018 21:45:37 -0700 Subject: [PATCH 2/3] Upgrade fs-extra and replace mkdirp Per https://github.com/unindented/electron-installer-debian/pull/96#discussion_r141490690 `fs.ensureDir` has `mode` documented, as of https://github.com/jprichardson/node-fs-extra/pull/587 --- package.json | 3 +-- src/installer.js | 19 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 2325a71..30c7fc5 100644 --- a/package.json +++ b/package.json @@ -36,11 +36,10 @@ "asar": "^0.14.0", "cross-spawn-promise": "^0.10.1", "debug": "^3.1.0", - "fs-extra": "^5.0.0", + "fs-extra": "^7.0.0", "get-folder-size": "^1.0.0", "glob": "^7.1.2", "lodash": "^4.17.4", - "mkdirp": "^0.5.1", "pify": "^3.0.0", "semver": "^5.4.1", "temp": "^0.8.3", diff --git a/src/installer.js b/src/installer.js index 03bf110..e352558 100644 --- a/src/installer.js +++ b/src/installer.js @@ -6,7 +6,6 @@ const debug = require('debug') const fs = require('fs-extra') const fsize = require('get-folder-size') const glob = require('glob') -const mkdirp = require('mkdirp') const path = require('path') const pify = require('pify') const temp = require('temp').track() @@ -211,7 +210,7 @@ function createControl (options, dir) { const controlDest = path.join(dir, 'DEBIAN/control') options.logger(`Creating control file at ${controlDest}`) - return pify(mkdirp)(path.dirname(controlDest), '0755') + return fs.ensureDir(path.dirname(controlDest), '0755') .then(() => generateTemplate(options, controlSrc)) .then(data => fs.outputFile(controlDest, data)) .catch(wrapError('creating control file')) @@ -244,7 +243,7 @@ function createBinary (options, dir) { const binDest = path.join(binDir, options.name) options.logger(`Symlinking binary from ${binSrc} to ${binDest}`) - return pify(mkdirp)(binDir, '0755') + return fs.ensureDir(binDir, '0755') .catch(wrapError('creating binary path')) .then(() => fs.symlink(binSrc, binDest, 'file')) .catch(wrapError('creating binary file')) @@ -260,7 +259,7 @@ function createDesktop (options, dir) { const desktopDest = path.join(dir, 'usr/share/applications', `${options.name}.desktop`) options.logger(`Creating desktop file at ${desktopDest}`) - return pify(mkdirp)(path.dirname(desktopDest), '0755') + return fs.ensureDir(path.dirname(desktopDest), '0755') .catch(wrapError('creating desktop path')) .then(() => generateTemplate(options, desktopSrc)) .then(data => fs.outputFile(desktopDest, data)) @@ -275,7 +274,7 @@ function createPixmapIcon (options, dir) { const iconFile = path.join(dir, 'usr/share/pixmaps', `${options.name}.png`) options.logger(`Creating icon file at ${iconFile}`) - return pify(mkdirp)(path.dirname(iconFile), '0755') + return fs.ensureDir(path.dirname(iconFile), '0755') .catch(wrapError('creating icon path')) .then(() => fs.copy(options.icon, iconFile)) .then(() => fs.chmod(iconFile, '0644')) @@ -291,7 +290,7 @@ function createHicolorIcon (options, dir) { const iconFile = path.join(dir, 'usr/share/icons/hicolor', resolution, 'apps', `${options.name}.${iconExt}`) options.logger(`Creating icon file at ${iconFile}`) - return pify(mkdirp)(path.dirname(iconFile), '0755') + return fs.ensureDir(path.dirname(iconFile), '0755') .then(() => fs.copy(icon, iconFile)) .then(() => fs.chmod(iconFile, '0644')) .catch(wrapError('creating icon file')) @@ -316,7 +315,7 @@ function createCopyright (options, dir) { const copyrightFile = path.join(dir, 'usr/share/doc', options.name, 'copyright') options.logger(`Creating copyright file at ${copyrightFile}`) - return pify(mkdirp)(path.dirname(copyrightFile), '0755') + return fs.ensureDir(path.dirname(copyrightFile), '0755') .then(() => copyLicense(options, copyrightFile)) .then(() => fs.chmod(copyrightFile, '0644')) .catch(wrapError('creating copyright file')) @@ -330,7 +329,7 @@ function createOverrides (options, dir) { const overridesDest = path.join(dir, 'usr/share/lintian/overrides', options.name) options.logger(`Creating lintian overrides at ${overridesDest}`) - return pify(mkdirp)(path.dirname(overridesDest), '0755') + return fs.ensureDir(path.dirname(overridesDest), '0755') .then(() => generateTemplate(options, overridesSrc)) .then(data => fs.outputFile(overridesDest, data)) .then(() => fs.chmod(overridesDest, '0644')) @@ -345,7 +344,7 @@ function createApplication (options, dir) { const licenseFile = path.join(applicationDir, 'LICENSE') options.logger(`Copying application to ${applicationDir}`) - return pify(mkdirp)(applicationDir, '0755') + return fs.ensureDir(applicationDir, '0755') .then(() => fs.copy(options.src, applicationDir)) .then(() => fs.unlink(licenseFile)) .catch(wrapError('copying application directory')) @@ -361,7 +360,7 @@ function createDir (options) { return pify(temp.mkdir)('electron-') .then(dir => { tempDir = path.join(dir, `${options.name}_${options.version}_${options.arch}`) - return pify(mkdirp)(tempDir, '0755') + return fs.ensureDir(tempDir, '0755') }) .catch(wrapError('creating temporary directory')) } From 7bbddc5dff1a8f90150a04b959a25ce97b71c335 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Tue, 2 Oct 2018 22:08:21 -0700 Subject: [PATCH 3/3] Upgrade dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 30c7fc5..f210741 100644 --- a/package.json +++ b/package.json @@ -35,16 +35,16 @@ "dependencies": { "asar": "^0.14.0", "cross-spawn-promise": "^0.10.1", - "debug": "^3.1.0", + "debug": "^4.0.1", "fs-extra": "^7.0.0", - "get-folder-size": "^1.0.0", + "get-folder-size": "^2.0.0", "glob": "^7.1.2", "lodash": "^4.17.4", - "pify": "^3.0.0", + "pify": "^4.0.0", "semver": "^5.4.1", "temp": "^0.8.3", "word-wrap": "^1.2.3", - "yargs": "^11.0.0" + "yargs": "^12.0.2" }, "devDependencies": { "chai": "^4.1.2", @@ -56,7 +56,7 @@ "eslint-plugin-standard": "^4.0.0", "mocha": "^5.0.5", "mz": "^2.7.0", - "nyc": "^11.4.1", + "nyc": "^13.0.1", "promise-retry": "^1.1.1" } }