1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 * Update: <srcdir>/tools/@types/index.d.ts,
9 * reference: <objdir>/dist/@types/lib.gecko.*.d.json,
10 * generated by a ts build lib step.
13 const fs = require("fs");
14 const libs = ["dom", "nsresult", "services", "xpcom"];
16 function main(index_dts, lib_dir) {
17 let index = fs.readFileSync(index_dts, "utf8");
19 for (let lib of libs) {
20 let file = `lib.gecko.${lib}.d.ts`;
21 let path = `${lib_dir}/${file}`;
22 let found = fs.existsSync(path);
23 console.log(`[INFO] ${path} (found: ${found})`);
26 let re = RegExp(` types=".+/${file}" />`);
27 index = index.replace(re, ` types="${path}" />`);
31 console.log(`[INFO] ${index_dts} (${index.length.toLocaleString()} bytes)`);
32 fs.writeFileSync(index_dts, index);
35 main(...process.argv.slice(2));