Skip to content

Commit

Permalink
feat: add packagePaths to options when calling ElectronInstaller.move…
Browse files Browse the repository at this point in the history
…Package() (#36)
  • Loading branch information
malept authored Jun 12, 2019
1 parent 1d61c6e commit e732241
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

[Unreleased]: https://github.com/electron-userland/electron-installer-common/compare/v0.7.1...master

### Added

* Add `packagePaths` to `options` when calling `ElectronInstaller.movePackage()`

## [0.7.1] - 2019-06-09

[0.7.1]: https://github.com/electron-userland/electron-installer-common/compare/v0.7.0...v0.7.1
Expand Down
8 changes: 6 additions & 2 deletions src/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,21 @@ class ElectronInstaller {

/**
* Move the package to the specified destination.
*
* Also adds `packagePaths` to `options`, which is an `Array` of the absolute paths to the
* moved packages.
*/
async movePackage () {
debug('Moving package to destination')

return error.wrapError('moving package files', async () => {
const files = await glob(this.packagePattern)
return Promise.all(files.map(async file => {
this.options.packagePaths = await Promise.all(files.map(async file => {
const renameTemplate = this.options.rename(this.options.dest, path.basename(file))
const dest = _.template(renameTemplate)(this.options)
debug(`Moving file ${file} to ${dest}`)
return fs.move(file, dest, { clobber: true })
await fs.move(file, dest, { clobber: true })
return dest
}))
})
}
Expand Down
4 changes: 3 additions & 1 deletion test/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ test('movePackage', t => {
await fs.ensureDir(destDir)
await fs.outputFile(path.join(dir.path, 'test.pkg'), 'hello')
await installer.movePackage()
await util.assertPathExists(t, path.join(destDir, 'test_foo.pkg'))
const expectedPackagePath = path.join(destDir, 'test_foo.pkg')
t.deepEqual(installer.options.packagePaths, [expectedPackagePath])
await util.assertPathExists(t, expectedPackagePath)
})
})

Expand Down

0 comments on commit e732241

Please sign in to comment.