Skip to content

Commit

Permalink
fix: failed to parse tsconfig.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzzen committed Mar 7, 2024
1 parent be1d5fe commit df2233e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ jobs:
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npx zx@7.2.3 build.mjs
- uses: denoland/setup-deno@v1
with:
deno-version: "1.41.1"
- run: deno run -A build.mjs
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
Expand Down
28 changes: 23 additions & 5 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env zx

// import "zx/globals";
import * as fs from "fs";
import "npm:zx@7.2.3/globals";
import { parse as parseJson } from "npm:jsonc-parser@3.2.1";
import * as fs from "node:fs";

const tsconfigPath = "./pyright/packages/pyright-internal/tsconfig.json";
const packagePath = "./pyright/packages/pyright-internal/package.json";

const tsconfig = require(tsconfigPath);
const packageJson = require(packagePath);
const tsconfig = await readJson(tsconfigPath);
const packageJson = await readJson(packagePath);

tsconfig.compilerOptions = Object.assign(tsconfig.compilerOptions, {
declaration: true,
Expand All @@ -26,8 +27,25 @@ cd("../../../");

const date = await $`date '+%Y%m%d'`;
packageJson.name = "@zzzen/pyright-internal";
packageJson.repository = "github:Zzzen/pyright-packager"
packageJson.repository = "github:Zzzen/pyright-packager";
packageJson.version = `1.2.0-dev.${date.stdout.trim()}`;
packageJson.private = false;

fs.writeFileSync("package.json", JSON.stringify(packageJson, undefined, 2));

/**
*
* @param {string} path
*/
async function readJson(path) {
const content = await Deno.readTextFile(path);
const errors = [];
const val = parseJson(content, errors, {
allowTrailingComma: true,
});
if (errors.length > 0) {
console.error(errors);
throw new Error(`failed to parse json: ${path}`);
}
return val;
}

0 comments on commit df2233e

Please sign in to comment.