Skip to content

Commit

Permalink
fix: use correct downloaded xpi file path (#124)
Browse files Browse the repository at this point in the history
* fix: use correct downloaded xpi file path

* test: use path to downloaded file directly

* refactor: remove unneeded var
  • Loading branch information
iamogbz committed Apr 20, 2020
1 parent 14ee1b8 commit 1b41d0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
12 changes: 3 additions & 9 deletions src/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ const publish = async options => {
const { FIREFOX_API_KEY, FIREFOX_SECRET_KEY } = process.env

const signAddon = async params => {
const unsignedXpiFile = `unsigned-${targetXpi}`
fs.writeFileSync(
path.join(artifactsDir, unsignedXpiFile),
fs.readFileSync(params.xpiPath),
)
const unsignedXpiFile = path.join(artifactsDir, `unsigned-${targetXpi}`)
fs.writeFileSync(unsignedXpiFile, fs.readFileSync(params.xpiPath))
const result = await defaultAddonSigner(params)
if (
channel === allowedChannels.LISTED &&
Expand All @@ -55,10 +52,7 @@ const publish = async options => {
{ signAddon },
)
const [xpiFile] = downloadedFiles
fs.renameSync(
path.join(artifactsDir, xpiFile),
path.join(artifactsDir, targetXpi),
)
fs.renameSync(xpiFile, path.join(artifactsDir, targetXpi))
}

module.exports = {
Expand Down
11 changes: 6 additions & 5 deletions tests/publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ describe('publish', () => {
it('renames downloaded file to target xpi', async () => {
const downloadedFile = 'mock_downloaded.xpi'
const mockFileContent = 'some fake signed xpi'
const downloadedFilePath = path.join(
mockOptions.artifactsDir,
downloadedFile,
)
vol.fromJSON({
[path.join(
mockOptions.artifactsDir,
downloadedFile,
)]: mockFileContent,
[downloadedFilePath]: mockFileContent,
})
signAddon.mockResolvedValueOnce({
...mockAddonSignSuccess,
downloadedFiles: [downloadedFile],
downloadedFiles: [downloadedFilePath],
})
const targetXpiPath = path.join(mockOptions.artifactsDir, targetXpi)
expect(fs.existsSync(targetXpiPath)).toBe(false)
Expand Down

0 comments on commit 1b41d0c

Please sign in to comment.