How to use the glob.glob 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 cs-education / classTranscribe / archive / utility_scripts / import.js View on Github external
*
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var fs = require("fs");

require("glob").glob("../captions/first/*.json", function (er, files) {
  console.log (files)
  files.forEach(function (filename) {
    var file = fs.readFileSync(filename).toString();
    console.log("// Part " + filename.split("Part_")[1].split("-")[0]);
    console.log(file + ",");
  });
});

require("glob").glob("../captions/second/*.json", function (er, files) {
  console.log (files)
  files.forEach(function (filename) {
    var file = fs.readFileSync(filename).toString();
    console.log("// Part " + filename.split("Part_")[1].split("-")[0]);
    console.log(file + ",");
  });
});
github assetgraph / assetgraph / lib / AssetConfigResolver.js View on Github external
['catch'](cb);
    }
    if (typeof assetConfig === 'string') {
        if (/^\//.test(assetConfig) && /^file:/.test(fromUrl) && /^file:/.test(that.root)) {
            assetConfig = {url: that.root + assetConfig.substr(1)};
        } else {
            assetConfig = {url: urlTools.resolveUrl(fromUrl, assetConfig)};
        }
    }
    if (assetConfig.url) {
        var protocol = assetConfig.url.substr(0, assetConfig.url.indexOf(':')),
            pathname = assetConfig.url.replace(/^\w+:(?:\/\/)?/, ""); // Strip protocol and two leading slashes if present
        if (protocol === 'file') {
            if (/[\*\?]/.test(pathname)) {
                // Expand wildcard, then expand each resulting url
                return glob.glob(pathname, error.passToFunction(cb, function (fsPaths) {
                    if (!fsPaths.length) {
                        cb(new Error("AssetGraph.resolveAssetConfig: Wildcard " + pathname + " expanded to nothing"));
                    } else {
                        that.resolve(fsPaths.map(function (fsPath) {
                            return 'file://' + fsPath;
                        }), fromUrl, cb);
                    }
                }));
            }
            assetConfig.rawSrcProxy = function (cb) {
                fs.readFile(pathname, null, cb);
            };
        } else if (protocol === 'http' || protocol === 'https') {
            assetConfig.rawSrcProxy = function (cb) {
                request({
                    url: assetConfig.url,
github streetmix / streetmix / lib / icons.js View on Github external
function compileSVGIcons () {
  // Inititalize svg-sprite
  const spriter = new SVGSpriter(config)

  // Read all individual SVG files, using`glob` to make it easier to grab *.svg
  // svg-sprite parses and optimizes each one, then compiles it
  // Then we pass output back to node `fs` to save it to system
  glob.glob('assets/images/icons/*.svg', function (error, files) {
    if (error) {
      logger.error(
        chalk`[glob] {red.bold ✗} {red Error reading SVG files: ${error}}`
      )
    }

    logger.info(chalk`[svg-sprite] {cyan Compiling SVG icons ...}`)

    files.forEach(function (file) {
      spriter.add(
        path.join(process.cwd(), file),
        // Path basename is what we use for the `id`, so file naming is important
        path.basename(file),
        fs.readFileSync(path.join(process.cwd(), file))
      )
    })
github sikuli / sieveable / lib / files_reader.js View on Github external
function get(cb){
    glob.glob(__dirname + '/../data/ui-xml/*', function(err, files) {

        var apps = {
            get: function(id){
                var file = files[id]
                return {
                    xml: fs.readFileSync(file, 'utf8') 
                }
            }
        }
        // var apps = files.map(function(file) {
        //     var app = {
        //         xml: fs.readFileSync(file, 'utf8')
        //     }        	
        //     return app
        // });
github projectstorm / react-diagrams / lib-demo-gallery / tests-e2e / generate-e2e.js View on Github external
let glob = require('glob');
let webpack = require('webpack');
let path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');

glob.glob(__dirname + '/../../demos/demo-*/index.tsx', {}, (err, files) => {
	let config = require('../../webpack.config');

	let entry = {};
	let copy = [];
	files.forEach(entryFile => {
		entry[path.basename(path.dirname(entryFile))] = 'val-loader?entry=' + entryFile + '!' + __dirname + '/entry.js';
		copy.push({ to: path.basename(path.dirname(entryFile)), from: __dirname + '/index.html' });
	});

	config = {
		entry: entry,
		plugins: [new CopyWebpackPlugin(copy)],
		output: {
			filename: '[name]/main.js',
			path: __dirname + '/../../dist/e2e'
		},
github mosen / buildy / buildy / lib / buildy.js View on Github external
filespec.forEach(function(f) {
            
            if (f.indexOf('?') > -1 || f.indexOf('*') > -1 || f.indexOf('[') > -1) {
                glob.glob(f, globFlags, fnGlobResults);
            } else {
                fnAddFiles([f]);
            }
        });
    },
github pshrmn / curi / packages / svelte / scripts / copyHTML.js View on Github external
fs.ensureDir(DIST).then(() => {
    glob.glob(path.join(SRC, "*.svelte"), function(err, files) {
      files.forEach(input => {
        const name = path.basename(input);
        const output = path.join(DIST, name);
        fs.createReadStream(input).pipe(fs.createWriteStream(output));
      });
    });
  });
}
github FabMo / FabMo-Engine / engine.js View on Github external
config.engine.set('platform', PLATFORM);
    }

    switch(OS) {
        case 'linux':
                    var ports = {
                        'control_port_linux' : '/dev/ttyACM0',
                        'data_port_linux' : '/dev/ttyACM0'
                    }
                    config.engine.update(ports, function() {
                        callback();
                    });
            break;
        case 'darwin':
            config.engine.set('server_port', 9876);
            glob.glob('/dev/cu.usbmodem*', function(err, files) {
                if(files.length >= 1) {
                    var ports = {
                        'control_port_osx' : files[0],
                        'data_port_osx' : files[1] || files[0]
                    }
                    config.engine.update(ports, function() {
                        callback();
                    });
                } else {
                    callback();
                }
            });
        break;

        default:
            callback();
github okgrow / graphql-markdown / src / server-helpers.js View on Github external
export const getListOfMdFiles = contentRoot =>
  Glob.glob.sync(`${contentRoot}/**/*.+(md|markdown)`);