From 7b797d3caf2d7beaa8d48b73a585e5c4f4400532 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sun, 21 Nov 2021 21:43:28 +0800 Subject: [PATCH] feat(cli): create pre-release if tag includes alpha/beta/rc --- cli/src/build.ts | 10 +++++----- cli/src/pre-publish.ts | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cli/src/build.ts b/cli/src/build.ts index f859b56c..dd9cae6a 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -1,4 +1,5 @@ import { execSync } from 'child_process' +import { existsSync } from 'fs' import { join, parse, sep } from 'path' import { Instance } from 'chalk' @@ -11,7 +12,6 @@ import { createJsBinding } from './js-binding-template' import { getDefaultTargetTriple, parseTriple } from './parse-triple' import { copyFileAsync, - existsAsync, mkdirAsync, readFileAsync, unlinkAsync, @@ -243,7 +243,7 @@ export class BuildCommand extends Command { 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) => { console.warn( chalk.bgYellowBright( @@ -260,7 +260,7 @@ export class BuildCommand extends Command { `${dylibName}${libExt}`, ) - if (await existsAsync(distModulePath)) { + if (existsSync(distModulePath)) { debug(`remove old binary [${chalk.yellowBright(distModulePath)}]`) await unlinkAsync(distModulePath) } @@ -312,7 +312,7 @@ export class BuildCommand extends Command { async function findUp(dir = process.cwd()): Promise { const dist = join(dir, 'target') - if (await existsAsync(dist)) { + if (existsSync(dist)) { return dir } const dirs = dir.split(sep) @@ -334,7 +334,7 @@ async function processIntermediateTypeFile( target: string, ): Promise { const idents: string[] = [] - if (!(await existsAsync(source))) { + if (!existsSync(source)) { debug(`do not find tmp type file. skip type generation`) return idents } diff --git a/cli/src/pre-publish.ts b/cli/src/pre-publish.ts index 73d20296..4c79d0d8 100644 --- a/cli/src/pre-publish.ts +++ b/cli/src/pre-publish.ts @@ -170,6 +170,10 @@ export class PrePublishCommand extends Command { owner, repo, tag_name: pkgInfo.tag, + prerelease: + version.includes('alpha') || + version.includes('beta') || + version.includes('rc'), }) } catch (e) { debug(