|
1 | 1 | import { execSync } from "node:child_process"; |
2 | | -import { mkdtempSync, readFileSync, writeFileSync } from "node:fs"; |
| 2 | +import { |
| 3 | + cpSync, |
| 4 | + mkdtempSync, |
| 5 | + readFileSync, |
| 6 | + rmSync, |
| 7 | + writeFileSync, |
| 8 | +} from "node:fs"; |
3 | 9 | import { tmpdir } from "node:os"; |
4 | 10 | import { join } from "node:path"; |
5 | 11 | import { resolve } from "node:path"; |
@@ -150,21 +156,17 @@ const publishPackage = ({ path, name }, shouldPublish) => { |
150 | 156 | console.log( |
151 | 157 | `npm_config_workspace=${process.env.npm_config_workspace || ""} npm_config_workspaces=${process.env.npm_config_workspaces || ""}` |
152 | 158 | ); |
| 159 | + const publishRoot = mkdtempSync(join(tmpdir(), "rescript-mui-publish-")); |
| 160 | + const tempPkgPath = join(publishRoot, path); |
| 161 | + cpSync(path, tempPkgPath, { recursive: true }); |
| 162 | + rmSync(join(tempPkgPath, "node_modules"), { recursive: true, force: true }); |
153 | 163 | pkgJson.version = targetVersion; |
154 | | - writePackageJson(path, pkgJson); |
155 | | - try { |
156 | | - const tgzName = run("npm pack --quiet", { cwd: path, env: npmEnv }); |
157 | | - const tgzPath = resolve(join(path, tgzName)); |
158 | | - console.log(`Packed tarball: ${tgzPath}`); |
159 | | - const publishCwd = mkdtempSync(join(tmpdir(), "rescript-mui-publish-")); |
160 | | - execSync(`npm publish ${tgzPath} --access public --tag ${distTag} --provenance`, { |
161 | | - cwd: publishCwd, |
162 | | - stdio: "inherit", |
163 | | - env: npmEnv, |
164 | | - }); |
165 | | - } finally { |
166 | | - execSync(`git checkout -- package.json`, { cwd: path }); |
167 | | - } |
| 164 | + writePackageJson(tempPkgPath, pkgJson); |
| 165 | + execSync(`npm publish --access public --tag ${distTag} --provenance`, { |
| 166 | + cwd: tempPkgPath, |
| 167 | + stdio: "inherit", |
| 168 | + env: npmEnv, |
| 169 | + }); |
168 | 170 | }; |
169 | 171 |
|
170 | 172 | const changedPaths = getChangedPaths(); |
|
0 commit comments