Skip to content

Commit ab2b21d

Browse files
committed
nodejs: improve tsconfig patcher
1 parent 26595ea commit ab2b21d

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/subsystems/nodejs/builders/granular/default.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,6 @@
386386
if [ -f ./tsconfig.json ] \
387387
&& node -e 'require("typescript")' &>/dev/null; then
388388
node ${./tsconfig-to-json.js}
389-
${pkgs.jq}/bin/jq ".compilerOptions.preserveSymlinks = true" tsconfig.json \
390-
| ${pkgs.moreutils}/bin/sponge tsconfig.json
391389
fi
392390
'';
393391

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
try {
2-
console.log(require.resolve("typescript"));
3-
} catch(e) {
4-
console.error("typescript is not found");
5-
process.exit(e.code);
2+
require.resolve("typescript");
3+
} catch (e) {
4+
process.exit(0);
65
}
76

8-
const ts = require("typescript")
9-
const fs = require('fs')
7+
const ts = require("typescript");
8+
const fs = require("fs");
109

1110
try {
12-
const data = fs.readFileSync('tsconfig.json', 'utf8')
11+
const data = fs.readFileSync("tsconfig.json", "utf8");
1312
} catch (err) {
14-
console.error(err)
13+
console.error(err);
1514
}
1615

17-
config = ts.parseConfigFileTextToJson(data)
18-
newdata = JSON.stringify(config)
19-
fs.writeFileSync('tsconfig.json', newdata);
16+
config = ts.parseConfigFileTextToJson(data);
17+
18+
// https://www.typescriptlang.org/tsconfig#preserveSymlinks
19+
config.compilerOptions.preserveSymlinks = true;
20+
21+
fs.writeFileSync("tsconfig.json", JSON.stringify(config));

0 commit comments

Comments
 (0)