Skip to content

Commit

Permalink
fix(publisher): fix ers publisher not publishing when version already…
Browse files Browse the repository at this point in the history
… exists

should use the artifact name comparison that was already coded, silly mistake
  • Loading branch information
MarshallOfSound committed May 3, 2017
1 parent a41d6db commit 1c643ef
Showing 1 changed file with 35 additions and 37 deletions.
72 changes: 35 additions & 37 deletions src/publishers/electron-release-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,46 +71,44 @@ export default async (artifacts, packageJSON, forgeConfig, authToken, tag, platf
'Content-Type': 'application/json',
},
});
}

let uploaded = 0;
await asyncOra(`Uploading Artifacts ${uploaded}/${artifacts.length}`, async (uploadSpinner) => {
const updateSpinner = () => {
uploadSpinner.text = `Uploading Artifacts ${uploaded}/${artifacts.length}`; // eslint-disable-line no-param-reassign
};
let uploaded = 0;
await asyncOra(`Uploading Artifacts ${uploaded}/${artifacts.length}`, async (uploadSpinner) => {
const updateSpinner = () => {
uploadSpinner.text = `Uploading Artifacts ${uploaded}/${artifacts.length}`; // eslint-disable-line no-param-reassign
};

await Promise.all(artifacts.map(artifactPath =>
new Promise(async (resolve, reject) => {
if (existingVersion) {
const existingAsset = existingVersion.assets.find(asset => asset.name === path.basename(artifactPath));
if (existingAsset) {
d('asset at path:', artifactPath, 'already exists on server');
uploaded += 1;
updateSpinner();
return;
}
}
try {
d('attempting to upload asset:', artifactPath);
const artifactForm = new FormData();
artifactForm.append('token', token);
artifactForm.append('version', packageJSON.version);
artifactForm.append('platform', ersPlatform(platform, arch));
artifactForm.append('file', fs.createReadStream(artifactPath));
await authFetch('api/asset', {
method: 'POST',
body: artifactForm,
headers: artifactForm.getHeaders(),
});
d('upload successful for asset:', artifactPath);
await Promise.all(artifacts.map(artifactPath =>
new Promise(async (resolve, reject) => {
if (existingVersion) {
const existingAsset = existingVersion.assets.find(asset => asset.name === path.basename(artifactPath));
if (existingAsset) {
d('asset at path:', artifactPath, 'already exists on server');
uploaded += 1;
updateSpinner();
} catch (err) {
reject(err);
return;
}
})
));
});
} else {
d('version already exists, not publishing');
}
}
try {
d('attempting to upload asset:', artifactPath);
const artifactForm = new FormData();
artifactForm.append('token', token);
artifactForm.append('version', packageJSON.version);
artifactForm.append('platform', ersPlatform(platform, arch));
artifactForm.append('file', fs.createReadStream(artifactPath));
await authFetch('api/asset', {
method: 'POST',
body: artifactForm,
headers: artifactForm.getHeaders(),
});
d('upload successful for asset:', artifactPath);
uploaded += 1;
updateSpinner();
} catch (err) {
reject(err);
}
})
));
});
};

0 comments on commit 1c643ef

Please sign in to comment.