diff --git a/scripts/publish.js b/scripts/publish.js index 62f2217b752bf..656c78d02cd83 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -7,10 +7,12 @@ const resetdeps = () => npm('run', 'resetdeps') const op = () => spawn('op', 'item', 'get', 'npm', '--otp', { out: true, ok: true }) -const getVersion = async (s) => { - const mani = await pacote.manifest(s, { preferOnline: true }) - return mani.version +const missingVersion = ({ name, version }) => { + const mani = await pacote.manifest(`${name}@${version}`, { preferOnline: true }) + .catch(() => null) + return !mani } + const getLatest = async (s) => { const pack = await pacote.packument(s, { preferOnline: true }) return pack['dist-tags'].latest @@ -35,9 +37,8 @@ const needsPublish = async ({ private, name, version }, { force, getTag }) => { return } - const tag = await getTag({ name, version }) - if (force || version !== await getVersion(`${name}@${tag}`)) { - return tag + if (force || await missingVersion({ name, version })) { + return getTag({ name, version }) } }