Skip to content

Commit 3d5066f

Browse files
committed
fixing audio bump
1 parent 3ad1401 commit 3d5066f

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
],
1717
"scripts": {
1818
"build": "tsc -p tsconfig.json",
19-
"prepublishOnly": "node scripts/bump-version.mjs && npm run build",
19+
"prepublishOnly": "npm run build",
2020
"version:registry": "node scripts/bump-version.mjs",
21+
"publish:registry": "node scripts/publish.mjs",
2122
"test": "jest --config jest.config.mjs",
2223
"test:unit": "jest --selectProjects unit",
2324
"test:wire": "jest --selectProjects wire"

scripts/publish.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env node
2+
import { execFileSync } from "node:child_process";
3+
import fs from "node:fs";
4+
import path from "node:path";
5+
import { fileURLToPath } from "node:url";
6+
7+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
8+
const rootDir = path.resolve(scriptDir, "..");
9+
const pkgPath = path.join(rootDir, "package.json");
10+
const lockPath = path.join(rootDir, "package-lock.json");
11+
const versionPath = path.join(rootDir, "src", "version.ts");
12+
13+
const bumpArg = process.argv[2] || process.env.BUMP || "patch";
14+
15+
const run = (cmd, args, options = {}) =>
16+
execFileSync(cmd, args, { encoding: "utf8", ...options }).trim();
17+
18+
const snapshots = new Map();
19+
const record = (filePath) => {
20+
if (fs.existsSync(filePath)) {
21+
snapshots.set(filePath, fs.readFileSync(filePath, "utf8"));
22+
}
23+
};
24+
25+
const restore = () => {
26+
for (const [filePath, contents] of snapshots.entries()) {
27+
fs.writeFileSync(filePath, contents, "utf8");
28+
}
29+
for (const filePath of [pkgPath, lockPath, versionPath]) {
30+
if (!snapshots.has(filePath) && fs.existsSync(filePath)) {
31+
fs.unlinkSync(filePath);
32+
}
33+
}
34+
};
35+
36+
record(pkgPath);
37+
record(lockPath);
38+
record(versionPath);
39+
40+
try {
41+
run("node", [path.join(rootDir, "scripts", "bump-version.mjs"), bumpArg], {
42+
cwd: rootDir,
43+
stdio: "inherit",
44+
});
45+
run("npm", ["run", "build"], { cwd: rootDir, stdio: "inherit" });
46+
run("npm", ["publish", "--ignore-scripts"], { cwd: rootDir, stdio: "inherit" });
47+
} finally {
48+
restore();
49+
}

0 commit comments

Comments
 (0)