Skip to content

Commit 294eee5

Browse files
Better npm publish config #3
1 parent 337d114 commit 294eee5

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

scripts/publish-npm.mjs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { execSync } from "node:child_process";
2-
import { readFileSync, writeFileSync } from "node:fs";
2+
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
3+
import { tmpdir } from "node:os";
34
import { join } from "node:path";
45

56
const ref = process.env.GITHUB_REF || "";
@@ -134,17 +135,18 @@ const publishPackage = ({ path, name }, shouldPublish) => {
134135
}
135136

136137
console.log(`Publishing ${name}@${targetVersion} with dist-tag ${distTag}`);
137-
const npmEnv = {
138-
...process.env,
139-
npm_config_workspaces: "false",
140-
npm_config_legacy_peer_deps: "true",
141-
npm_config_ignore_workspace_root_check: "true",
142-
};
138+
const npmEnv = { ...process.env };
139+
delete npmEnv.npm_config_workspace;
140+
delete npmEnv.npm_config_workspaces;
141+
delete npmEnv.npm_config_workspaces_enabled;
143142
pkgJson.version = targetVersion;
144143
writePackageJson(path, pkgJson);
145144
try {
146-
execSync(`npm publish --access public --tag ${distTag}`, {
147-
cwd: path,
145+
const tgzName = run("npm pack --quiet", { cwd: path, env: npmEnv });
146+
const tgzPath = join(path, tgzName);
147+
const publishCwd = mkdtempSync(join(tmpdir(), "rescript-mui-publish-"));
148+
execSync(`npm publish ${tgzPath} --access public --tag ${distTag}`, {
149+
cwd: publishCwd,
148150
stdio: "inherit",
149151
env: npmEnv,
150152
});

0 commit comments

Comments
 (0)