How to use the glob.glob.sync function in glob

To help you get started, we’ve selected a few glob examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / pulito / webpack.common.js View on Github external
function pageFinder(dir, webpack_config, minifyOutput) {
  // Look at all sub-directories of dir and if a directory contains
  // both a -demo.html and -demo.js file then add the corresponding
  // entry points and Html plugins to the config.

  // Find all the dirs below 'dir'.
  const pagesDir = path.resolve(dir, 'pages');
  // Look for all *.js files, for each one look for a matching .html file.
  // Emit into config.
  //
  const pagesJS = glob.sync(pagesDir + '/*.js');

  pagesJS.forEach(pageJS => {
    // Look for both a .js and .html file in the directory.
    // Strip off ".js" from end and replace with ".html".
    let pageHTML = pageJS.replace(/\.js$/, '.html');
    if (!fs.existsSync(pageHTML)) {
      console.log("WARNING: A page needs both a *.js and a *.html file.");
      return
    }

    let baseHTML = basename(pageHTML);
    let name = basename(pageJS, '.js');
    webpack_config.entry[name] = pageJS;
    let opts = {
      filename: baseHTML,
      template: pageHTML,
github google / skia-buildbot / pulito / webpack.common.js View on Github external
function pageFinder(dir, webpack_config) {
  // Look at all sub-directories of dir and if a directory contains
  // both a -demo.html and -demo.js file then add the corresponding
  // entry points and Html plugins to the config.

  // Find all the dirs below 'dir'.
  const pagesDir = path.resolve(dir, 'pages');
  // Look for all *.js files, for each one look for a matching .html file.
  // Emit into config.
  //
  const pagesJS = glob.sync(pagesDir + '/*.js');

  pagesJS.forEach(pageJS => {
    // Look for both a .js and .html file in the directory.
    // Strip off ".js" from end and replace with ".html".
    let pageHTML = pageJS.replace(/\.js$/, '.html');
    if (!fs.existsSync(pageHTML)) {
      console.log("WARNING: A page needs both a *.js and a *.html file.");
      return
    }

    let baseHTML = basename(pageHTML);
    let name = basename(pageJS, '.js');
    webpack_config.entry[name] = pageJS;
    webpack_config.plugins.push(
      new HtmlWebpackPlugin({
        filename: baseHTML,
github steveblue / architect / build_tools / src / util.ts View on Github external
export function optimizeBuild(
    options: AbstractBuilderSchema | RollupBuilderSchema | ClosureBuilderSchema,
    context: BuilderContext
  ): Observable<{}> {

    // TODO: convert to Observable pattern
    const files = glob.sync(normalize('out-tsc/**/*.component.js'));

    return of(Promise.all(files.map((file) => {
        return new Promise((res, rej) => {
            readFile(file, 'utf-8', (err, data) => {
            if (err) rej(err);
            writeFile(file, buildOptimizer({ content: data }).content, (err) => {
                if (err) rej(err);
                res(file);
            });
        });
        })
    })));

}
github google / skia-buildbot / common-sk / webpack.config.js View on Github external
module.exports = (env, argv) => {
  let config = commonBuilder(env, argv, __dirname);

  config.entry.tests = glob.sync('./modules/**/*_test.js');
  return config;
}
github google / skia-buildbot / res / mod / webpack.config.js View on Github external
const { commonBuilder } = require('./webpack.common.js');
const { demoFinder } = require('./webpack.demo-finder.js')
const { glob } = require('glob');

let common = demoFinder(__dirname, commonBuilder(__dirname));
common.entry.tests = glob.sync('./tests/*.js');

module.exports = common;
github sysgears / spinjs / src / BuilderDiscoverer.ts View on Github external
      ? _.flatten(rootConfig.workspaces.map((ws: string) => glob.sync(ws))).map((ws: string) => path.join(this.cwd, ws))
      : [this.cwd];
github sysgears / create-apollo-app / packages / spinjs / src / BuilderDiscoverer.ts View on Github external
      ? _.flatten(rootConfig.workspaces.map((ws: string) => glob.sync(ws))).map((ws: string) => path.join(this.cwd, ws))
      : [this.cwd];
github sysgears / larix / packages / zen / src / BuilderDiscoverer.ts View on Github external
      ? _.flatten(rootConfig.workspaces.map((ws: string) => glob.sync(ws))).map((ws: string) => path.join(this.cwd, ws))
      : [this.cwd];