Skip to content

Commit

Permalink
chore: check version to determine whether to publish (#5811)
Browse files Browse the repository at this point in the history
Co-authored-by: Gar <gar+gh@danger.computer>
  • Loading branch information
lukekarrys and wraithgar committed Nov 3, 2022
1 parent c10abe0 commit 9931679
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scripts/publish.js
Expand Up @@ -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
Expand All @@ -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 })
}
}

Expand Down

0 comments on commit 9931679

Please sign in to comment.