From 665b5b12ffba29e0cb3f9fcf9f1a67aca29e8a31 Mon Sep 17 00:00:00 2001 From: Vladislav Mamon Date: Mon, 15 Nov 2021 09:35:29 +0500 Subject: [PATCH] ci: fix npm and release scripts --- package.json | 6 +++--- scripts/release.ts | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index b46b536..a483acb 100644 --- a/package.json +++ b/package.json @@ -30,13 +30,13 @@ "scripts": { "build": "npm run build:types && npm run build:rollup", "build:types": "tsc -p tsconfig.types.json", - "build:rollup": "tsm scripts/compile.ts", + "build:rollup": "npx tsm scripts/compile.ts", "fmt:prettier": "prettier --write \"**/*.{js,ts,json}\"", "fmt:style": "eslint --fix --ext .js,.ts .", "postbuild": "rimraf dist/types", - "postversion": "tsm scripts/release.ts restore", + "postversion": "npx tsm ../scripts/release.ts restore", "prebuild": "rimraf dist", - "prepack": "tsm scripts/release.ts prepare", + "prerelease": "npx tsm scripts/release.ts prepare", "prepare": "husky install", "release": "npx semantic-release", "release:dry": "npx semantic-release --dry-run", diff --git a/scripts/release.ts b/scripts/release.ts index adced39..5bb5423 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -1,5 +1,6 @@ import { access, copyFile } from 'fs/promises' import { constants } from 'fs' +import { resolve } from 'path' interface Success { kind: 'success' @@ -71,15 +72,15 @@ async function main() { } }, - /** This should be called in `postversion`. */ + /** This should be called in `postversion`. Here we actually are inside the `dist`. */ async restore() { try { // Copy back. - await copyFile(`${cwd}/dist/package.json`, `${cwd}/package.json`) + await copyFile(`${cwd}/package.json`, resolve(cwd, '..', 'package.json')) return { kind: 'success', - message: 'Successfully prepared files for a release.' + message: 'Successfully restored `package.json`.' } } catch (error) { return {