Skip to content

Commit

Permalink
nodejs: improve tsconfig patcher
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens committed Aug 23, 2022
1 parent 5346ba7 commit 28d1b2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/subsystems/nodejs/builders/granular/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,6 @@
if [ -f ./tsconfig.json ] \
&& node -e 'require("typescript")' &>/dev/null; then
node ${./tsconfig-to-json.js}
${pkgs.jq}/bin/jq ".compilerOptions.preserveSymlinks = true" tsconfig.json \
| ${pkgs.moreutils}/bin/sponge tsconfig.json
fi
'';

Expand Down
24 changes: 13 additions & 11 deletions src/subsystems/nodejs/builders/granular/tsconfig-to-json.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
try {
console.log(require.resolve("typescript"));
} catch(e) {
console.error("typescript is not found");
process.exit(e.code);
require.resolve("typescript");
} catch (e) {
process.exit(0);
}

const ts = require("typescript")
const fs = require('fs')
const ts = require("typescript");
const fs = require("fs");

try {
const data = fs.readFileSync('tsconfig.json', 'utf8')
const data = fs.readFileSync("tsconfig.json", "utf8");
} catch (err) {
console.error(err)
console.error(err);
}

config = ts.parseConfigFileTextToJson(data)
newdata = JSON.stringify(config)
fs.writeFileSync('tsconfig.json', newdata);
config = ts.parseConfigFileTextToJson(data);

// https://www.typescriptlang.org/tsconfig#preserveSymlinks
config.compilerOptions.preserveSymlinks = true;

fs.writeFileSync("tsconfig.json", JSON.stringify(config));

0 comments on commit 28d1b2a

Please sign in to comment.