mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-30 09:55:18 +00:00
Make project multiplatform (#91)
* Prefer `c ? x : y` over `c && x || y` * Avoid unnecessary asssignment expressions * Prefer switch statements over object lookup tables * Add an .editorconfig * Fix style issues * Fix mentioned issues * remove dynamic require * Introduce esbuild as a build system * Add cross platform stream api * Replace 'fs' with custom cache api * Add cross platform crypto api * Add misc. dependencies * Create multi-platform tests * Update package-lock, Add build files * Pull from upstream * Fix linting issues, and update build files * Fix comments issues * Regenerate types, add source maps Co-authored-by: bob <bob.varioa@gmail.com>
This commit is contained in:
31
scripts/build-parser-json.js
Normal file
31
scripts/build-parser-json.js
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
const glob = require('glob');
|
||||
const fs = require('fs');
|
||||
|
||||
const json = [ '{' ];
|
||||
|
||||
glob.sync('../lib/parser/contents/classes/**/*.js', { cwd: __dirname }).forEach((
|
||||
file
|
||||
) => {
|
||||
// Trim path
|
||||
file = file.replace('../lib/parser/contents/classes/', '').replace('.js', '');
|
||||
json.push(`'${file}': () => require('./classes/${file}'),`);
|
||||
});
|
||||
|
||||
json.push('}');
|
||||
fs.writeFileSync(
|
||||
'./lib/parser/contents/map.js',
|
||||
`/* eslint-disable */
|
||||
// This file was automatically generated, do not edit
|
||||
// See ./scripts/build-parser-json.js
|
||||
const map = ${json.join('')};
|
||||
module.exports = function req(name) {
|
||||
const func = map[name];
|
||||
if (!func) {
|
||||
const error = new Error('Module not found: ' + name);
|
||||
error.code = 'MODULE_NOT_FOUND';
|
||||
throw error;
|
||||
}
|
||||
return func();
|
||||
}`
|
||||
);
|
||||
Reference in New Issue
Block a user