How to use the 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 zerkalica / reactive-di / test / tests.js View on Github external
global.window = win

const hasOwnProperty = {}.hasOwnProperty

function propagateToGlobal(window: Object) {
    for (let key in window) { // eslint-disable-line
        if (hasOwnProperty.call(window, key) && !(key in global)) {
            global[key] = window[key]
        }
    }
}

propagateToGlobal(win)


glob.sync(__dirname + '/spec/**/*.js').forEach((file) => require(file)) // eslint-disable-line
github ballerina-attic / composer / modules / distribution / pre-build.js View on Github external
function prepareService() {
    // search for service jar
    let foundFiles = glob.sync(serviceBuild);

    if(foundFiles.length !== 1) {
        console.error('Error while searching for service build file.');
    }

    fs.createReadStream(foundFiles[0]).pipe(fs.createWriteStream(path.join(__dirname, 'workspace-service.jar')));
}
github SFantasy / express-load-router / index.js View on Github external
function loadRouter(app, root, options) {
  const opt = options || {};

  glob.sync(`${root}/**/*.js`).forEach((file) => {
    const realRoot = os.platform() === 'win32' ? root.replace(/\\/ig, '/') : root;
    const filePath = file.replace(/\.[^.]*$/, '');
    const controller = require(filePath);
    const urlPrefix = filePath.replace(realRoot, '').replace(/\/index$/, '');
    const methods = Object.keys(controller);

    // Handle options
    const excludeRules = opt.excludeRules || [];
    const rewriteRules = opt.rewriteRules || new Map();

    function applyMethod(name, methodBody) {
      const body = methodBody;
      let modifiedUrl = `${urlPrefix}${name === 'index' ? '' : `/${name}`}`;
      let middlewares = [];
      let method = 'get';
      let handler;
github handsontable / hot-builder / src / projectDescriptor / modulesDiscover / index.js View on Github external
ModulesDiscover.prototype.discover = function() {
  var modulePaths;

  // TODO: Already we support only plugins/*.
  modulePaths = glob.sync(fs.realpathSync(this.project.getPath()) + '/src/plugins/*/');

  if (this.project.isPro()) {
    modulePaths = modulePaths.concat(glob.sync(fs.realpathSync(this.project.getPath()) + '/node_modules/handsontable/src/plugins/*/'));
  }

  modulePaths.forEach(function(modulePath) {
    // Searching only js files (ignoring tests).
    var files = glob.sync('**/*(@([^_]*).js)', {
      cwd: modulePath,
      ignore: ['test/**'],
    }).map(function(fileName) {
      return path.resolve(path.join(modulePath, fileName));
    });

    var item = new ItemDescriptor({
      path: modulePath,
      files: files,
    });
    this.discoveredModules.push(item);
github cibernox / ember-power-select / fastboot-tests / runner.js View on Github external
function addFiles(mocha, files) {
  files = (typeof files === 'string') ? glob.sync(root + files) : files;
  files.forEach(mocha.addFile.bind(mocha));
}
github spryker / demoshop / gulp / zed.js View on Github external
gulp.task('assets', function() {
    console.log('\nListing all the assets files in the project...'.yellow);

    var assets = glob.sync(basePath + '/**/assets.*.*.json');
    assets.forEach(function(asset) {
        console.log(asset.replace(basePath, ''));
    });

    console.log('{0} files found\n'.format(assets.length).yellow);
});
github tutao / tutanota / buildSrc / prepareMobileBuild.js View on Github external
}

	const imagesPath = prefix + "images"
	if (fs.existsSync(imagesPath)) {
		const imageFiles = glob.sync(prefix + "images/*")
		for (let file of imageFiles) {
			if (!file.endsWith("ionicons.ttf")) {
				console.log("unlinking ", file)
				fs.unlinkSync(file)
			}
		}
	} else {
		console.log("No folder at", imagesPath)
	}

	const maps = glob.sync(prefix + "*.js.map")
	for (let file of maps) {
		console.log("unlinking ", file)
		fs.unlinkSync(file)
	}
	const indexHtmlPath = prefix + "index.html"
	if (fs.existsSync(indexHtmlPath)) {
		fs.unlinkSync(indexHtmlPath)
		console.log("rm ", indexHtmlPath)
	} else {
		console.log("no file at", indexHtmlPath)
	}
}
github liferay / generator-liferay-fragments / utils / get-project-content.js View on Github external
function _getCollectionFragments(collectionDirectory) {
  return glob
    .sync(path.join(collectionDirectory, '*', 'fragment.json'))
    .map(
      /** @param {string} fragmentJSON */
      fragmentJSON => path.resolve(fragmentJSON, '..')
    )
    .filter(directory => {
      try {
        _readJSONSync(path.resolve(directory, 'fragment.json'));
        return true;
      } catch (error) {
        log(`✘ Invalid ${directory}/fragment.json, fragment ignored`, {
          level: 'LOG_LEVEL_ERROR'
        });

        return false;
      }
github djyde / serlina / packages / serlina / lib / serlina.ts View on Github external
get _pageEntries() {
    const pagesPath = path.resolve(this.options.baseDir, './pages')

    const pages = glob.sync('**/*.*', {
      cwd: pagesPath
    })

    return pages as string[]
  }
github SE7ENSKY / webpack-verstat / bin / core.js View on Github external
function generateEntry(server) {
	const entry = glob.sync(`${PROJECT_ROOT}/src/assets/*.js`);
	if (entry.length) {
		const obj = {};
		const file = entry[0];
		const objProp = basename(file, '.js');
		obj[objProp] = [file.replace(SOURCE_DIRECTORY, '.')];
		if (Array.isArray(server)) {
			server.reverse().forEach(item => obj[objProp].unshift(item));
		}
		return obj;
	}
	return null;
}