Skip to content

Commit 96774b8

Browse files
committed
💥 Drop support for Node.js < 8.5.x
Migration Guide: Upgrade to Node.js 8.5.0 or newer.
1 parent df34242 commit 96774b8

File tree

5 files changed

+37
-42
lines changed

5 files changed

+37
-42
lines changed

‎lib/appdmg.js‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,10 @@ module.exports = exports = function (options) {
163163
async.each(global.files, function (file, cb) {
164164
const path = resolvePath(file.path)
165165

166-
fs.exists(path, function (exists) {
167-
if (exists) {
166+
util.pathExists(path, function (err, exists) {
167+
if (err) {
168+
cb(err)
169+
} else if (exists) {
168170
cb(null)
169171
} else {
170172
cb(new Error(`"${file.path}" not found at: ${path}`))
@@ -262,11 +264,13 @@ module.exports = exports = function (options) {
262264
function copyPlainBackground (next) {
263265
const finalPath = path.join(global.bkgdir, path.basename(global.opts.background))
264266
global.bkgname = path.join('.background', path.basename(global.opts.background))
265-
util.cp(absolutePath, finalPath, next)
267+
fs.copyFile(absolutePath, finalPath, next)
266268
}
267269

268-
fs.exists(retinaPath, function (exists) {
269-
if (exists) {
270+
util.pathExists(retinaPath, function (err, exists) {
271+
if (err) {
272+
return next(err)
273+
} else if (exists) {
270274
copyRetinaBackground(next)
271275
} else {
272276
copyPlainBackground(next)
@@ -296,7 +300,7 @@ module.exports = exports = function (options) {
296300
pipeline.addStep('Copying icon', function (next) {
297301
if (global.opts.icon) {
298302
const finalPath = path.join(global.temporaryMountPath, '.VolumeIcon.icns')
299-
util.cp(resolvePath(global.opts.icon), finalPath, next)
303+
fs.copyFile(resolvePath(global.opts.icon), finalPath, next)
300304
} else {
301305
next.skip()
302306
}
@@ -422,10 +426,10 @@ module.exports = exports = function (options) {
422426
**/
423427

424428
pipeline.addStep('Signing image', function (next) {
425-
var codeSignOptions = global.opts['code-sign']
429+
const codeSignOptions = global.opts['code-sign']
426430
if (codeSignOptions && codeSignOptions['signing-identity']) {
427-
var codeSignIdentity = codeSignOptions['signing-identity']
428-
var codeSignIdentifier = codeSignOptions['identifier']
431+
const codeSignIdentity = codeSignOptions['signing-identity']
432+
const codeSignIdentifier = codeSignOptions['identifier']
429433
util.codesign(codeSignIdentity, codeSignIdentifier, global.target, next)
430434
} else {
431435
return next.skip()

‎lib/util.js‎

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
'use strict'
22

33
const execa = require('execa')
4+
const pathExists = require('path-exists')
5+
const util = require('util')
46
const xattr = require('fs-xattr')
5-
const cpFile = require('cp-file')
6-
const alloc = require('buffer-alloc')
77

88
exports.sh = function (prog, args, cb) {
9-
execa(prog, args).then(function (result) {
10-
setImmediate(cb, null, result)
11-
}).catch(function (err) {
12-
setImmediate(cb, err)
13-
})
14-
}
15-
16-
exports.cp = function (source, target, cb) {
17-
cpFile(source, target).then(function () {
18-
setImmediate(cb, null)
19-
}).catch(function (err) {
20-
setImmediate(cb, err)
21-
})
9+
util.callbackify(() => execa(prog, args))(cb)
2210
}
2311

2412
exports.dusm = function (path, cb) {
25-
exports.sh('du', ['-sm', path], function (err, res) {
13+
exports.sh('du', ['-sm', path], (err, res) => {
2614
if (err) return cb(err)
2715

2816
if (res.stderr.length > 0) {
@@ -44,16 +32,20 @@ exports.tiffutil = function (a, b, out, cb) {
4432
}
4533

4634
exports.seticonflag = function (path, cb) {
47-
const buf = alloc(32)
35+
const buf = Buffer.alloc(32)
4836
buf.writeUInt8(4, 8)
49-
xattr.set(path, 'com.apple.FinderInfo', buf, cb)
37+
util.callbackify(() => xattr.set(path, 'com.apple.FinderInfo', buf))(cb)
5038
}
5139

5240
exports.codesign = function (identity, identifier, path, cb) {
53-
var args = ['--verbose', '--sign', identity]
41+
let args = ['--verbose', '--sign', identity]
5442
if (identifier) {
5543
args.push('--identifier', identifier)
5644
}
5745
args.push(path)
58-
exports.sh('codesign', args, function (err) { cb(err) })
46+
exports.sh('codesign', args, (err) => cb(err))
47+
}
48+
49+
exports.pathExists = function (path, cb) {
50+
util.callbackify(() => pathExists(path))(cb)
5951
}

‎package.json‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@
77
"repository": "LinusU/node-appdmg",
88
"dependencies": {
99
"async": "^1.4.2",
10-
"buffer-alloc": "^1.1.0",
11-
"cp-file": "^3.1.0",
1210
"ds-store": "^0.1.5",
13-
"execa": "^0.4.0",
11+
"execa": "^1.0.0",
1412
"fs-temp": "^1.0.0",
15-
"fs-xattr": "^0.1.14",
16-
"image-size": "^0.5.0",
17-
"is-my-json-valid": "^2.13.1",
13+
"fs-xattr": "^0.3.0",
14+
"image-size": "^0.7.4",
15+
"is-my-json-valid": "^2.20.0",
1816
"minimist": "^1.1.3",
1917
"parse-color": "^1.0.0",
18+
"path-exists": "^4.0.0",
2019
"repeat-string": "^1.5.4"
2120
},
2221
"engines": {
23-
"node": ">=4"
22+
"node": ">=8.5"
2423
},
2524
"os": [
2625
"darwin"
@@ -30,8 +29,8 @@
3029
},
3130
"devDependencies": {
3231
"capture-window": "^0.1.3",
33-
"looks-same": "^2.1.0",
34-
"mocha": "^2.2.5",
35-
"standard": "^7.0.1"
32+
"looks-same": "^7.2.1",
33+
"mocha": "^6.1.4",
34+
"standard": "^12.0.1"
3635
}
3736
}

‎test/api.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ function runAppdmg (opts, verify, cb) {
2323

2424
ee.on('finish', function () {
2525
try {
26-
assert.equal(progressCalled, STEPS * 2)
27-
assert.equal(imageFormat(opts.target), verify.format)
26+
assert.strictEqual(progressCalled, STEPS * 2)
27+
assert.strictEqual(imageFormat(opts.target), verify.format)
2828
} catch (err) {
2929
return cb(err)
3030
}

‎test/lib/visually-verify-image.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function captureAndVerify (title, expectedPath, cb) {
3535

3636
// If the actual size is scaled by two, use the retina image.
3737
if (actualSize.width === expectedSize.width * 2 && actualSize.height === expectedSize.height * 2) {
38-
expectedPath = expectedPath.replace(/(\.[^\.]*)$/, '@2x$1')
38+
expectedPath = expectedPath.replace(/(\.[^.]*)$/, '@2x$1')
3939
}
4040

4141
looksSame(pngPath, expectedPath, toleranceOpts, function (err1, ok) {

0 commit comments

Comments
 (0)