Skip to content

Commit

Permalink
feat!: require Node 12 (LTS) (#70)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Drop support for Node < 12.13.0

* refactor: remove direct dependency on fs-extra
* refactor: remove devDependency on rimraf
* chore: ignore package manager error logs
* refactor: replace cross-zip with extract-zip
* chore(gitignore): yarn.lock is in git
* chore(deps): upgrade debug to ^4.3.2
* build(deps-dev): upgrade eslint-plugin-import to ^2.23.4
* chore: replace .npmignore with package.json files
* build(deps-dev): upgrade mocha to ^9.0.3
* chore: remove unused .jsfmtrc file
* build(deps-dev): upgrade eslint to ^7.32.0
* build(deps-dev): upgrade eslint-config-airbnb-base to ^14.2.1
* ci: test with the minimum required Node.js version
  • Loading branch information
malept authored Aug 3, 2021
1 parent 269e686 commit 42793b7
Show file tree
Hide file tree
Showing 10 changed files with 803 additions and 980 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: macOS-latest
strategy:
matrix:
node-version: [8.x, 12.x, 16.x]
node-version: [12.13.0, 14.x, 16.x]

steps:
- uses: actions/checkout@v2.3.4
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*-error.log
node_modules/
.DS_Store
npm-debug.log
package-lock.json
yarn.lock
test/fixture*
168 changes: 0 additions & 168 deletions .jsfmtrc

This file was deleted.

4 changes: 0 additions & 4 deletions .npmignore

This file was deleted.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

> Create DMG installers for your electron apps using [appdmg][appdmg].
## Requirements

This module requires using macOS and Node 12 (LTS) or above.

## Installation

**For use in npm scripts:**
Expand Down
2 changes: 1 addition & 1 deletion bin/electron-installer-dmg.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (args.debug) {
process.env.DEBUG = 'electron-installer-dmg';
}

const createDMG = require('../');
const createDMG = require('..');
const pkg = require('../package.json');

const [appPath, name] = args._;
Expand Down
22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@
"electron-installer-dmg": "bin/electron-installer-dmg.js"
},
"engines": {
"node": ">= 8.0.0"
"node": ">= 12.13.0"
},
"files": [
"bin",
"resources",
"src",
"usage.txt"
],
"dependencies": {
"debug": "^4.1.1",
"fs-extra": "^8.0.1",
"debug": "^4.3.2",
"minimist": "^1.1.1"
},
"optionalDependencies": {
Expand All @@ -31,12 +36,11 @@
"license": "Apache-2.0",
"devDependencies": {
"@electron/get": "^1.1.0",
"cross-zip": "^2.1.5",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-plugin-import": "^2.13.0",
"mocha": "^6.1.4",
"rimraf": "^3.0.2"
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.4",
"extract-zip": "^2.0.1",
"mocha": "^9.0.3"
},
"keywords": [
"mongodb.js",
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const debug = require('debug')('electron-installer-dmg');
const fs = require('fs-extra');
const { existsSync, promises: fs } = require('fs');
const os = require('os');
const path = require('path');

Expand Down Expand Up @@ -84,7 +84,7 @@ module.exports = async (immutableOpts) => {

opts.dmgPath = path.resolve(opts.dmgPath || path.join(opts.out, `${opts.name}.dmg`));

await fs.ensureDir(path.dirname(opts.dmgPath));
await fs.mkdir(path.dirname(opts.dmgPath), { recursive: true });
opts.format = opts.format || 'UDZO';

opts.contents = opts.contents || [
Expand All @@ -106,7 +106,7 @@ module.exports = async (immutableOpts) => {
opts.contents = opts.contents(opts);
}

if (await fs.pathExists(opts.dmgPath)) {
if (existsSync(opts.dmgPath)) {
if (!opts.overwrite) {
debug('DMG already exists at `%s` and overwrite is false', opts.dmgPath);
const msg = `DMG already exists. Run electron-installer-dmg again with \
Expand Down
22 changes: 8 additions & 14 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
const assert = require('assert');
const { download } = require('@electron/get');
const fs = require('fs-extra');
const { existsSync, promises: fs } = require('fs');
const path = require('path');
const { promisify } = require('util');
const rimraf = require('rimraf');
const zip = require('cross-zip');

const unzip = promisify(zip.unzip);
const unzip = require('extract-zip');

const MINUTES_IN_MS = 60 * 1000;

Expand All @@ -16,7 +12,7 @@ describe('electron-installer-dmg', () => {
});

it('should be requireable', () => {
assert.doesNotThrow(() => require('../')); // eslint-disable-line global-require
assert.doesNotThrow(() => require('..')); // eslint-disable-line global-require
});

describe('with app', () => {
Expand All @@ -26,25 +22,23 @@ describe('electron-installer-dmg', () => {
this.timeout(2 * MINUTES_IN_MS);

const zipPath = await download('2.0.4');
await unzip(zipPath, appPath);
await unzip(zipPath, { dir: appPath });
});

it('should succeed in creating a DMG', async function testCreate() {
this.timeout(2 * MINUTES_IN_MS);
const createDMG = require('../'); // eslint-disable-line global-require
const createDMG = require('..'); // eslint-disable-line global-require
const dmgPath = path.resolve(__dirname, 'fixture.dmg');
await createDMG({
appPath,
dmgPath,
name: 'Test App',
});
assert(await fs.pathExists(dmgPath), 'dmg should exist');
assert(existsSync(dmgPath), 'dmg should exist');
});

afterEach(() => fs.unlink(`${appPath}.dmg`));
afterEach(async () => fs.unlink(`${appPath}.dmg`));

after(() => {
rimraf.sync(appPath);
});
after(async () => fs.rmdir(appPath, { recursive: true }));
});
});
Loading

0 comments on commit 42793b7

Please sign in to comment.