From e185e53e3460ae0230810443036f60dc73b7abfc Mon Sep 17 00:00:00 2001 From: XLor Date: Mon, 11 Jul 2022 17:36:39 +0000 Subject: [PATCH] fix: compatiable esm --- package.json | 4 ++-- pnpm-lock.yaml | 18 +++++++++--------- src/cli.ts | 3 ++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index a7739b11..e2c3732d 100644 --- a/package.json +++ b/package.json @@ -63,8 +63,8 @@ "prettier": "^2.7.1", "typescript": "^4.7.4", "unbuild": "^0.7.4", - "vite": "^2.9.13", - "vitest": "^0.17.1" + "vite": "^2.9.14", + "vitest": "^0.18.0" }, "packageManager": "pnpm@7.5.0", "engines": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1b310e2f..da66b6b4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ importers: prettier: ^2.7.1 typescript: ^4.7.4 unbuild: ^0.7.4 - vite: ^2.9.13 - vitest: ^0.17.1 + vite: ^2.9.14 + vitest: ^0.18.0 dependencies: axios: 0.27.2_debug@4.3.4 cac: 6.7.12 @@ -36,8 +36,8 @@ importers: prettier: 2.7.1 typescript: 4.7.4 unbuild: 0.7.4 - vite: 2.9.13 - vitest: 0.17.1 + vite: 2.9.14 + vitest: 0.18.0 packages: @@ -1680,8 +1680,8 @@ packages: - supports-color dev: true - /vite/2.9.13: - resolution: {integrity: sha512-AsOBAaT0AD7Mhe8DuK+/kE4aWYFMx/i0ZNi98hJclxb4e0OhQcZYUrvLjIaQ8e59Ui7txcvKMiJC1yftqpQoDw==} + /vite/2.9.14: + resolution: {integrity: sha512-P/UCjSpSMcE54r4mPak55hWAZPlyfS369svib/gpmz8/01L822lMPOJ/RYW6tLCe1RPvMvOsJ17erf55bKp4Hw==} engines: {node: '>=12.2.0'} hasBin: true peerDependencies: @@ -1704,8 +1704,8 @@ packages: fsevents: 2.3.2 dev: true - /vitest/0.17.1: - resolution: {integrity: sha512-d6NsFC6FPmZ5XdiSYfW5rwJ/b8060wqe2steNNlVbhO69HWma6CucIm5g7PXlCSkmKvrdEbUsZHPAarlH83VGw==} + /vitest/0.18.0: + resolution: {integrity: sha512-ryAtlh5Gvg3+aLNuOQ8YOHxgQCCu46jx40X5MBL0K0/ejB9i5zsr8fV8LTGXbXex80UMHlzceI9F+ouGaiR+mQ==} engines: {node: '>=v14.16.0'} hasBin: true peerDependencies: @@ -1734,7 +1734,7 @@ packages: local-pkg: 0.4.1 tinypool: 0.2.1 tinyspy: 0.3.3 - vite: 2.9.13 + vite: 2.9.14 transitivePeerDependencies: - less - sass diff --git a/src/cli.ts b/src/cli.ts index 75d7a598..c13476ca 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,6 +1,7 @@ import path from 'path'; import createDebug from 'debug'; import { lightRed } from 'kolorist'; +import { fileURLToPath } from 'url'; import { existsSync, writeFileSync } from 'fs'; import { version } from '../package.json'; @@ -42,7 +43,7 @@ async function main(args: string[]) { if (_filename) { const filename = _filename.endsWith('.ts') ? _filename : _filename + '.ts'; if (!existsSync(filename)) { - const globalsDts = path.join(__dirname, '../globals.d.ts'); + const globalsDts = path.join(fileURLToPath(import.meta.url), '../../globals.d.ts'); const template = [ '#!/usr/bin/env optc', '',