lib/support/browserScript.js
async function scriptsFromDirectory(dirpath) {
  const dir = (await readdir(dirpath))
    .map(name => toFullPath(name, dirpath))
    .filter(await filters.onlyFiles)
    .filter(filters.onlyWithExtension('.js'));
  const result = {};
  for (const filepath of dir) {
    const name = path.basename(filepath, '.js');
    const script = await readFile(filepath, 'utf8');
    result[name] = script;
  }
  return result;
}
async function scriptsFromDirectory(dirpath) {
  const dir = (await readdir(dirpath))
    .map(name => toFullPath(name, dirpath))
    .filter(await filters.onlyFiles)
    .filter(filters.onlyWithExtension('.js'));
  const result = {};
  for (const filepath of dir) {
    const name = path.basename(filepath, '.js');
    const script = await readFile(filepath, 'utf8');
    result[name] = script;
  }
  return result;
}
async function scriptsFromDirectory ( dirpath ) { const dir = ( await readdir ( dirpath ) ) . map ( name => toFullPath ( name , dirpath ) ) . filter ( await filters . onlyFiles ) . filter ( filters . onlyWithExtension ( '.js' ) ) ; const result = { } ; for ( const filepath of dir ) { const name = path . basename ( filepath , '.js' ) ; const script = await readFile ( filepath , 'utf8' ) ; result [ name ] = script ; } return result ; }
Read all JavaScript files in a specific dir. Will use the filename
without .js as the name of the script.
@param {*} dirpath
Read all JavaScript files in a specific dir . Will use the filename without . js as the name of the script .