Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(run): tsx bin path #9152

Merged
merged 1 commit into from Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/plugin-run/src/index.ts
@@ -1,9 +1,9 @@
import assert from 'assert';
import { fork } from 'child_process';
import { writeFileSync } from 'fs';
import { dirname, join, resolve } from 'path';
import { dirname, join } from 'path';
import { IApi } from 'umi';
import { fsExtra } from 'umi/plugin-utils';
import { fsExtra, resolve } from 'umi/plugin-utils';

export default (api: IApi) => {
api.describe({
Expand Down Expand Up @@ -49,9 +49,10 @@ export default (api: IApi) => {
};

export function getBinPath() {
const pkgPath = join(__dirname, '../node_modules/tsx/package.json');
// tsx does not export `package.json` subpath, use `resolve` instead of `require.resolve`
const pkgPath = resolve.sync('tsx/package.json', { basedir: __dirname });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try resolve in privatenumber/tsx#91

const pkgContent = require(pkgPath);
return resolve(dirname(pkgPath), pkgContent.bin);
return join(dirname(pkgPath), pkgContent.bin);
}

export function getFileNameByPath(params: string) {
Expand Down