-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: using @types/gecko from gecko-dev
- Loading branch information
1 parent
e063415
commit 35c5a06
Showing
9 changed files
with
66,265 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Octokit } from "octokit"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
// Download all files in https://github.com/mozilla/gecko-dev/tree/master/tools/@types to types/gecko | ||
|
||
const GITHUB_TOKEN = process.env.GITHUB_TOKEN; | ||
|
||
const octokit = new Octokit({ auth: GITHUB_TOKEN }); | ||
|
||
const owner = "mozilla"; | ||
const repo = "gecko-dev"; | ||
const dir = "tools/@types"; | ||
|
||
async function main() { | ||
const { data: files } = await octokit.rest.repos.getContent({ | ||
owner, | ||
repo, | ||
path: dir, | ||
}); | ||
|
||
for (const file of files) { | ||
let { data: fileContent } = await octokit.rest.repos.getContent({ | ||
owner, | ||
repo, | ||
path: file.path, | ||
mediaType: { | ||
format: "raw", | ||
}, | ||
}); | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 500)); | ||
|
||
const filePath = path.join("types/gecko", file.name); | ||
if (file.name === "lib.gecko.dom.d.ts") { | ||
// Remove no-default-lib to avoid conflict with lib.d.ts | ||
fileContent = fileContent.replace( | ||
'/// <reference no-default-lib="true" />', | ||
"", | ||
); | ||
} | ||
fs.writeFileSync(filePath, fileContent, { encoding: "utf-8" }); | ||
} | ||
} | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* NOTE: Do not modify this file by hand. | ||
* Run `mach ts update` to reference typelibs generated in <objdir>. | ||
*/ | ||
|
||
/// <reference types="./lib.gecko.dom.d.ts" /> | ||
/// <reference types="./lib.gecko.nsresult.d.ts" /> | ||
/// <reference types="./lib.gecko.services.d.ts" /> | ||
/// <reference types="./lib.gecko.xpcom.d.ts" /> |
Oops, something went wrong.