feat(cli): create pre-release if tag includes alpha/beta/rc

This commit is contained in:
LongYinan 2021-11-21 21:43:28 +08:00
parent f0617ae129
commit 7b797d3caf
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
2 changed files with 9 additions and 5 deletions

View file

@ -1,4 +1,5 @@
import { execSync } from 'child_process' import { execSync } from 'child_process'
import { existsSync } from 'fs'
import { join, parse, sep } from 'path' import { join, parse, sep } from 'path'
import { Instance } from 'chalk' import { Instance } from 'chalk'
@ -11,7 +12,6 @@ import { createJsBinding } from './js-binding-template'
import { getDefaultTargetTriple, parseTriple } from './parse-triple' import { getDefaultTargetTriple, parseTriple } from './parse-triple'
import { import {
copyFileAsync, copyFileAsync,
existsAsync,
mkdirAsync, mkdirAsync,
readFileAsync, readFileAsync,
unlinkAsync, unlinkAsync,
@ -243,7 +243,7 @@ export class BuildCommand extends Command {
const parsedDist = parse(distModulePath) const parsedDist = parse(distModulePath)
if (parsedDist.dir && !(await existsAsync(parsedDist.dir))) { if (parsedDist.dir && !existsSync(parsedDist.dir)) {
await mkdirAsync(parsedDist.dir, { recursive: true }).catch((e) => { await mkdirAsync(parsedDist.dir, { recursive: true }).catch((e) => {
console.warn( console.warn(
chalk.bgYellowBright( chalk.bgYellowBright(
@ -260,7 +260,7 @@ export class BuildCommand extends Command {
`${dylibName}${libExt}`, `${dylibName}${libExt}`,
) )
if (await existsAsync(distModulePath)) { if (existsSync(distModulePath)) {
debug(`remove old binary [${chalk.yellowBright(distModulePath)}]`) debug(`remove old binary [${chalk.yellowBright(distModulePath)}]`)
await unlinkAsync(distModulePath) await unlinkAsync(distModulePath)
} }
@ -312,7 +312,7 @@ export class BuildCommand extends Command {
async function findUp(dir = process.cwd()): Promise<string | null> { async function findUp(dir = process.cwd()): Promise<string | null> {
const dist = join(dir, 'target') const dist = join(dir, 'target')
if (await existsAsync(dist)) { if (existsSync(dist)) {
return dir return dir
} }
const dirs = dir.split(sep) const dirs = dir.split(sep)
@ -334,7 +334,7 @@ async function processIntermediateTypeFile(
target: string, target: string,
): Promise<string[]> { ): Promise<string[]> {
const idents: string[] = [] const idents: string[] = []
if (!(await existsAsync(source))) { if (!existsSync(source)) {
debug(`do not find tmp type file. skip type generation`) debug(`do not find tmp type file. skip type generation`)
return idents return idents
} }

View file

@ -170,6 +170,10 @@ export class PrePublishCommand extends Command {
owner, owner,
repo, repo,
tag_name: pkgInfo.tag, tag_name: pkgInfo.tag,
prerelease:
version.includes('alpha') ||
version.includes('beta') ||
version.includes('rc'),
}) })
} catch (e) { } catch (e) {
debug( debug(