@@ -15,8 +15,6 @@ import { readConfig } from "./readConfig.js";
15
15
import * as render from "./render/index.js" ;
16
16
import { major , minor } from "semver" ;
17
17
import { getExitCode } from "./getExitCode.js" ;
18
- import { determinePackCommand , determineTarballFilename } from "./utils.js" ;
19
- import detectPackageManager from "which-pm-runs" ;
20
18
21
19
const packageJson = createRequire ( import . meta. url ) ( "../package.json" ) ;
22
20
const version = packageJson . version ;
@@ -76,8 +74,8 @@ particularly ESM-related module resolution issues.`,
76
74
. option ( "--exclude-entrypoints <entrypoints...>" , "Specify entrypoints to exclude from checking." )
77
75
. option (
78
76
"--entrypoints-legacy" ,
79
- " In packages without the `exports` field, every file is an entry point. Specifying this option " +
80
- " only takes effect when no entrypoints are automatically detected, or explicitly provided with other options." ,
77
+ ' In packages without the `exports` field, every file is an entry point. Specifying this option ' +
78
+ ' only takes effect when no entrypoints are automatically detected, or explicitly provided with other options.'
81
79
)
82
80
. addOption (
83
81
new Option ( "--ignore-rules <rules...>" , "Specify rules to ignore" ) . choices ( Object . values ( problemFlags ) ) . default ( [ ] ) ,
@@ -161,30 +159,29 @@ particularly ESM-related module resolution issues.`,
161
159
) ;
162
160
}
163
161
164
- const packageManager = ( await detectPackageManager ( ) ?. name ) ?? "npm" ;
165
- const packCommand = determinePackCommand ( packageManager ) ;
166
-
167
162
if ( ! opts . pack ) {
168
163
if ( ! process . stdout . isTTY ) {
169
164
program . error (
170
- ` Specifying a directory requires the --pack option to confirm that running \` ${ packCommand } \ ` is ok.` ,
165
+ " Specifying a directory requires the --pack option to confirm that running `npm pack ` is ok." ,
171
166
) ;
172
167
}
173
168
const rl = readline . createInterface ( process . stdin , process . stdout ) ;
174
169
const answer = await new Promise < string > ( ( resolve ) => {
175
- rl . question ( `Run \`${ packCommand } \`? (Pass -P/--pack to skip) (Y/n) ` , resolve ) ;
170
+ rl . question ( `Run \`npm pack \`? (Pass -P/--pack to skip) (Y/n) ` , resolve ) ;
176
171
} ) ;
177
172
rl . close ( ) ;
178
173
if ( answer . trim ( ) && ! answer . trim ( ) . toLowerCase ( ) . startsWith ( "y" ) ) {
179
174
process . exit ( 1 ) ;
180
175
}
181
176
}
182
177
183
- fileName = deleteTgz = await determineTarballFilename ( fileOrDirectory ) ;
184
-
185
- const packCommandWithFilename = determinePackCommand ( packageManager , fileName ) ;
186
-
187
- execSync ( packCommandWithFilename , { cwd : fileOrDirectory , encoding : "utf8" , stdio : "ignore" } ) ;
178
+ const manifest = JSON . parse ( await readFile ( path . join ( fileOrDirectory , "package.json" ) , { encoding : "utf8" } ) ) ;
179
+ fileName = deleteTgz = path . join (
180
+ fileOrDirectory ,
181
+ // https://github.com/npm/cli/blob/f875caa86900122819311dd77cde01c700fd1817/lib/utils/tar.js#L123-L125
182
+ `${ manifest . name . replace ( "@" , "" ) . replace ( "/" , "-" ) } -${ manifest . version } .tgz` ,
183
+ ) ;
184
+ execSync ( "npm pack" , { cwd : fileOrDirectory , encoding : "utf8" , stdio : "ignore" } ) ;
188
185
}
189
186
const file = await readFile ( fileName ) ;
190
187
const data = new Uint8Array ( file ) ;
0 commit comments