How to use the glob.GlobSync 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 aerogear / graphback / src / schema / SchemaGenerator.ts View on Github external
private registerPartials() {
    const partialsPath = join(__dirname, `partials`);
    const templates = new GlobSync('./*.handlebars', { cwd: partialsPath });
    templates.found.forEach((path: string) => {
      logger.debug("Adding new partial", path);
      // tslint:disable-next-line:no-any
      let name: any = basename(path).split('.');
      if (name.length > 0) {
        name = name[0];
      }
      const location = join(partialsPath, path);
      const content = readFileSync(location, { encoding: "UTF8" });
      handlebars.registerPartial(name, content);
    });
  }
}
github aerogear / graphback / packages / graphql-migrations / src / production / database / migrations / DataResourcesManager.ts View on Github external
public async dropDatabaseSchema() {
    try {
      if (this.client === 'sqlite3') {
        const sqliteFile = new GlobSync('*.sqlite', { cwd: process.cwd() })
        if (sqliteFile.found.length) {
          unlinkSync(`${process.cwd()}/${sqliteFile.found[0]}`)
        }
      } else {
        await this.getConnection().raw('DROP SCHEMA public CASCADE;')
        // tslint:disable-next-line: await-promise
        await this.getConnection().raw('CREATE SCHEMA public;')
      }

    } catch (err) {
      this.handleError(err)
    }
  }
github formulahendry / vscode-dotnet-test-explorer / src / vsTestPlatform / vsTestDotNet / vsTestDotNetModel.ts View on Github external
public getAdditionalTestAdapters(workspace: string): Array {
        const globPattern = path.join(workspace, this.config.output, "**", "**.TestAdapter.dll");
        const files = new GlobSync(globPattern, { matchBase: true }).found;
        return files;
    }
}
github gfrancischini / vscode-unit-test / src / utils / directory.ts View on Github external
export function getAllTestFilesInDirectory(directory, globExp): Array {
    let globPattern = path.join(directory, globExp);
    const fileTestList = new GlobSync(globPattern, null).found;
    return fileTestList;
}
github aerogear / graphback / packages / graphback-cli / src / helpers / db.ts View on Github external
export const createDBResources = async (config: ProjectConfig): Promise => {
  let databaseOperations: any[];
  try {
    const { db: { database }, folders } = config;

    const models = new GlobSync(`${folders.model}/*.graphql`)

    if (models.found.length === 0) {
      logError(`No graphql file found inside ${process.cwd()}/model folder.`)
      process.exit(0)
    }

    if (database === 'sqlite3') {
      await execa('touch', ['db.sqlite'])
    }

    const dbConfig = {
      client: config.db.database,
      connection: config.db.dbConfig
    }

    const schemaText = loadSchema(folders.model);
github aerogear / graphback / packages / graphback-cli / src / helpers / generate.ts View on Github external
export async function generateBackend(): Promise {
  try {
    const models = new GlobSync('model/*.graphql', { cwd: process.cwd() })

    if (models.found.length === 0) {
      logError(`No graphql file found inside ${process.cwd()}/model folder.`)
      process.exit(0)
    }
    const configPath = `${process.cwd()}/config.json`

    const { database, generation } = JSON.parse(readFileSync(configPath, "utf8"))

    const { templateType } = JSON.parse(readFileSync(`${process.cwd()}/.template.json`, 'utf8'))

    const path: string = process.cwd()
    const schemaText: string = models.found.map((m: string) => readFileSync(`${path}/${m}`, 'utf8')).join('\n')

    const outputSchemaPath: string = `${process.cwd()}/src/schema/generated.ts`
    const outputResolverPath: string = `${process.cwd()}/src/resolvers`
github aerogear / graphback / packages / graphback-cli / src / helpers / transformOpenApiSpec.ts View on Github external
export const transformOpenApiSpec = async () => {
    const configInstance = new ConfigBuilder();
    checkDirectory(configInstance);

    const { folders, openApi } = configInstance.config;
    const models = new GlobSync(`${folders.model}/*.yaml`)
    const jsonModels = new GlobSync(`${folders.model}/*.json`)

    if (models.found.length === 0 && jsonModels.found.length === 0) {
        logError(`No OpenAPI file found inside model folder.`)
        process.exit(0)
    }

    for (const model of jsonModels.found) {
        await processSingleDefinition(model, false, openApi);
    }

    for (const model of models.found) {
        await processSingleDefinition(model, true, openApi);
    }

    logInfo(`
   Successfully generated GraphQL schema from OpenAPI definition.
github forcedotcom / lightning-language-server / packages / lwc-language-server / src / context.ts View on Github external
public getRelativeModulesDirs(): string[] {
        const list: string[] = [];
        switch (this.type) {
            case WorkspaceType.SFDX:
                new GlobSync(`${this.sfdxPackageDirsPattern}/**/lwc/`, { cwd: this.workspaceRoot }).found.forEach(dirPath => {
                    list.push(dirPath);
                });
                break;

            case WorkspaceType.CORE_ALL:
                for (const project of fs.readdirSync(this.workspaceRoot)) {
                    const modulesDir = join(project, 'modules');
                    if (fs.existsSync(join(this.workspaceRoot, modulesDir))) {
                        list.push(modulesDir);
                    }
                }
                break;

            case WorkspaceType.CORE_SINGLE_PROJECT:
                list.push('modules');
                break;
github joelday / papyrus-lang / packages / papyrus-lang / src / host / NodeFileSystem.ts View on Github external
public findFilesAsUris(globPattern: string): string[] {
        return new GlobSync(normalize(globPattern)).found.map((f) =>
            URI.file(f).toString()
        );
    }