Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add packagePaths to options when calling ElectronInstaller.movePackage() #36

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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