aboutsummaryrefslogtreecommitdiff
path: root/misctools/publish-examples.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-03-02 19:02:10 -0800
committerGravatar GitHub <noreply@github.com> 2023-03-02 19:02:10 -0800
commit9388b3f8257bc2e580deaece4cd2677928104fc6 (patch)
tree3f6aff2009cef69897f599fe51305b894f81a376 /misctools/publish-examples.js
parentb469e5035161286abeb1a7726518d1afcc163a51 (diff)
downloadbun-9388b3f8257bc2e580deaece4cd2677928104fc6.tar.gz
bun-9388b3f8257bc2e580deaece4cd2677928104fc6.tar.zst
bun-9388b3f8257bc2e580deaece4cd2677928104fc6.zip
Add a zig fmt action (#2277)
* Add a zig fmt action * add failing file * Setup prettier better * Update prettier-fmt.yml * Fail on error * Update prettier-fmt.yml * boop * boop2 * tar.gz * Update zig-fmt.yml * Update zig-fmt.yml * Update zig-fmt.yml * Update zig-fmt.yml * Update zig-fmt.yml * boop * Update prettier-fmt.yml * tag * newlines * multiline * fixup * Update zig-fmt.yml * update it * fixup * both * w * Update prettier-fmt.yml * prettier all the things * Update package.json * zig fmt * ❌ ✅ * bump * . * quotes * fix prettier ignore * once more * Update prettier-fmt.yml * Update fallback.ts * consistentcy --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'misctools/publish-examples.js')
-rw-r--r--misctools/publish-examples.js51
1 files changed, 13 insertions, 38 deletions
diff --git a/misctools/publish-examples.js b/misctools/publish-examples.js
index 4124d0785..dcbb0d3eb 100644
--- a/misctools/publish-examples.js
+++ b/misctools/publish-examples.js
@@ -14,10 +14,7 @@ const DRY_RUN = !!process.env.DRY_RUN;
var count = 0;
-const examplesFolderEntries = fs.readdirSync(
- path.join(process.cwd(), "examples"),
- { withFileTypes: true },
-);
+const examplesFolderEntries = fs.readdirSync(path.join(process.cwd(), "examples"), { withFileTypes: true });
const packageNames = [];
@@ -28,10 +25,7 @@ for (let folder of examplesFolderEntries) {
let packageJSONText;
try {
- packageJSONText = fs.readFileSync(
- path.join(absolute, "package.json"),
- "utf8",
- );
+ packageJSONText = fs.readFileSync(path.join(absolute, "package.json"), "utf8");
} catch {
continue;
}
@@ -43,9 +37,7 @@ for (let folder of examplesFolderEntries) {
var version = "0.0.1";
try {
- const _versions = exec(`npm view ${packageJSON.name} versions --json`)
- .toString()
- .trim();
+ const _versions = exec(`npm view ${packageJSON.name} versions --json`).toString().trim();
if (_versions.length > 0) {
const versionsArray = JSON.parse(_versions);
@@ -70,10 +62,7 @@ for (let folder of examplesFolderEntries) {
} catch (exception) {}
try {
- fs.copyFileSync(
- path.join(absolute, ".gitignore"),
- path.join(absolute, "gitignore"),
- );
+ fs.copyFileSync(path.join(absolute, ".gitignore"), path.join(absolute, "gitignore"));
} catch (exception) {}
restart: while (retryCount-- > 0) {
@@ -85,18 +74,13 @@ for (let folder of examplesFolderEntries) {
delete packageJSON.main;
}
- fs.writeFileSync(
- path.join(absolute, "package.json"),
- JSON.stringify(packageJSON, null, 2),
- );
+ fs.writeFileSync(path.join(absolute, "package.json"), JSON.stringify(packageJSON, null, 2));
try {
exec(`npm version patch --force --no-commit-hooks --no-git-tag-version`, {
cwd: absolute,
});
- packageJSON = JSON.parse(
- fs.readFileSync(path.join(absolute, "package.json"), "utf8"),
- );
+ packageJSON = JSON.parse(fs.readFileSync(path.join(absolute, "package.json"), "utf8"));
version = packageJSON.version;
} catch (e) {
if (e.code !== "E404") {
@@ -105,12 +89,9 @@ for (let folder of examplesFolderEntries) {
}
try {
- exec(
- `npm publish ${
- DRY_RUN ? "--dry-run" : ""
- } --access public --registry https://registry.npmjs.org/`,
- { cwd: absolute },
- );
+ exec(`npm publish ${DRY_RUN ? "--dry-run" : ""} --access public --registry https://registry.npmjs.org/`, {
+ cwd: absolute,
+ });
packageNames.push([
packageJSON.name,
{
@@ -147,16 +128,10 @@ if (packageNames.length > 0) {
recursive: true,
});
} catch (exception) {}
- fs.writeFileSync(
- path.join(dir, "package.json"),
- JSON.stringify(packageJSON, null, 2),
- );
- exec(
- `npm publish ${
- DRY_RUN ? "--dry-run" : ""
- } --access public --registry https://registry.npmjs.org/`,
- { cwd: dir },
- );
+ fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify(packageJSON, null, 2));
+ exec(`npm publish ${DRY_RUN ? "--dry-run" : ""} --access public --registry https://registry.npmjs.org/`, {
+ cwd: dir,
+ });
}
console.log(`Published ${count} packages`);