-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide modules with reference without docs and examples
- Loading branch information
Showing
7 changed files
with
85 additions
and
5 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
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
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
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,34 @@ | ||
#!/usr/bin/env node | ||
import {existsSync, mkdirSync, readFileSync, writeFileSync} from 'fs'; | ||
import glob from 'glob'; | ||
import unassert from 'rollup-plugin-unassert'; | ||
import flow from '@mapbox/flow-remove-types'; | ||
import {dirname, join} from 'path'; | ||
|
||
const removeAssert = unassert({include: [/\.js$/]}); | ||
|
||
async function main() { | ||
const files = glob.sync('**/*.js', { | ||
ignore: ['+(bin|build|node_modules|dist)/**/*', 'rollup.config.js', 'test.js', 'prepare_modules.js'] | ||
}); | ||
for (let i = 0, ii = files.length; i < ii; i++) { | ||
const path = files[i]; | ||
console.log(path); | ||
let file = readFileSync(path, 'utf8'); | ||
file = flow(file, path).toString(); | ||
const {code} = await removeAssert.transform(file, path); | ||
const dir = join('dist', dirname(path)); | ||
if (!existsSync(dir)) { | ||
mkdirSync(dir); | ||
} | ||
writeFileSync(join('dist', path), code, 'utf8'); | ||
} | ||
|
||
if (!existsSync(join('dist', 'reference'))) { | ||
mkdirSync('dist/reference'); | ||
} | ||
const fullSpecJson = readFileSync('./reference/v8.json', 'utf8'); | ||
const minifiedSpec = JSON.parse(fullSpecJson, (key, value) => ['doc', 'example'].includes(key) ? undefined : value); | ||
writeFileSync('./dist/reference/v8.json', JSON.stringify(minifiedSpec), 'utf8'); | ||
} | ||
main(); |