Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
65 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,42 @@ | ||
import { cwd } from 'process'; | ||
import { extname, resolve } from 'path'; | ||
import { promises as fsPromises } from 'fs'; | ||
|
||
const { readdir, writeFile, unlink } = fsPromises | ||
|
||
async function* getFiles(dir) { | ||
const dirents = await readdir(dir, { withFileTypes: true }); | ||
|
||
for (const dirent of dirents) { | ||
const { name } = dirent; | ||
const fullPath = resolve(dir, name); | ||
|
||
if (dirent.isDirectory()) { | ||
yield* getFiles(fullPath); | ||
} else { | ||
yield { name, fullPath }; | ||
} | ||
} | ||
} | ||
|
||
(async function main() { | ||
const cwdpath = cwd(); | ||
const library = 'kotlinx.coroutines'; | ||
|
||
for await (const { name, fullPath } of getFiles(cwdpath)) { | ||
if (name === 'navigation.html') await unlink(fullPath); | ||
else { | ||
const ext = extname(name); | ||
|
||
if (ext === '.html') { | ||
let relativeUrl = fullPath.substring(cwdpath.length + 1); | ||
|
||
if (name === 'index.html') | ||
relativeUrl = relativeUrl.substring(0, relativeUrl.length - 'index.html'.length); | ||
|
||
const url = new URL(`/api/${library}/${relativeUrl}`, 'https://kotlinlang.org'); | ||
await writeFile(fullPath, `<script>window.location = '${url}' + window.location.hash;</script><meta http-equiv="refresh" content="0; url=${url}"/>`); | ||
} | ||
} | ||
} | ||
})(); |
This file was deleted.
Oops, something went wrong.