當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript globby.default函數代碼示例

本文整理匯總了TypeScript中globby.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: lintAsync

export async function lintAsync(filePatterns = defaultFilePatterns) {
  const filePaths = await globby(filePatterns);
  const contents = await Promise.all(filePaths.map(filePath => fs.readFileAsync(filePath, 'utf8')));
  const results = filePaths.map((filePath, index) => {
    const content = contents[index];
    const linter = new TsLinter(filePath, content, options);
    return linter.lint();
  });

  const failures = results.filter(result => !!result.failureCount);
  return failures;
}
開發者ID:Mercateo,項目名稱:typedocs,代碼行數:12,代碼來源:tslint.ts

示例2: resource

export default async function resource(compiler: NexeCompiler, next: () => Promise<any>) {
  const { cwd } = compiler.options
  if (!compiler.options.resources.length) {
    return next()
  }
  const step = compiler.log.step('Bundling Resources...')
  let count = 0
  await each(globs(compiler.options.resources, { cwd }), async file => {
    if (await isDirectoryAsync(file)) {
      return
    }
    count++
    step.log(`Including file: ${file}`)
    await compiler.addResource(file)
  })
  step.log(`Included ${count} file(s). ${(compiler.resourceSize / 1e6).toFixed(3)} MB`)
  return next()
}
開發者ID:jaredallard,項目名稱:nexe,代碼行數:18,代碼來源:resource.ts

示例3: reset

  public async reset() {
    this.logWithMetadata(['info', 'optimize:watch_cache'], 'The optimizer watch cache will reset');

    // start by deleting the state file to lower the
    // amount of time that another process might be able to
    // successfully read it once we decide to delete it
    await del(this.statePath);

    // delete everything in optimize/.cache directory
    // except ts-node
    await del(
      await globby(
        [
          normalizePosixPath(this.cachePath),
          `${normalizePosixPath(`!${this.cachePath}/ts-node/**`)}`,
        ],
        { dot: true }
      )
    );

    // delete some empty folder that could be left
    // from the previous cache path reset action
    await deleteEmpty(this.cachePath);

    // delete dlls
    await del(this.dllsPath);

    // re-write new cache state file
    await this.write();

    this.logWithMetadata(['info', 'optimize:watch_cache'], 'The optimizer watch cache has reset');
  }
開發者ID:lucabelluccini,項目名稱:kibana,代碼行數:32,代碼來源:watch_cache.ts

示例4: writeFileAsync

export async function formatAsync(filePatterns = sourceFilePatterns) {
  const filePaths = await globby(filePatterns, { absolute: true });
  const contents = await Promise.all(
    filePaths.map(filePath => readFileAsync(filePath, 'utf8'))
  );

  const fixedFiles: string[] = [];
  await Promise.all(
    filePaths.map(async (filePath, index) => {
      const content = contents[index];
      let formattedContent;

      try {
        formattedContent = format(content, options);
      } catch (err) {
        error(`Couldn't format ${red(filePath)}.`);
        throw err;
      }

      if (content !== formattedContent) {
        fixedFiles.push(filePath);
        await writeFileAsync(filePath, formattedContent);
      }
    })
  );

  return fixedFiles;
}
開發者ID:otbe,項目名稱:ws,代碼行數:28,代碼來源:prettier.ts

示例5: buildProductionProjects

    async () => {
      await buildProductionProjects({ kibanaRoot: tmpDir, buildRoot, onlyOSS: true });

      const files = await globby(['**/*', '!**/node_modules/**'], {
        cwd: buildRoot,
      });

      expect(files.sort()).toMatchSnapshot();
    },
開發者ID:elastic,項目名稱:kibana,代碼行數:9,代碼來源:build_production_projects.test.ts

示例6: getIntlLocales

export async function getIntlLocales(): Promise<LocaleMap> {
  if (!cachedLocales) {
    const intlPath = await resolve('intl');
    const cwd = join(dirname(intlPath), 'locale-data/jsonp');
    const localeFiles = await globby('*.js', { cwd });
    const locales = localeFiles.map((file) => basename(file, '.js'));
    cachedLocales = {};
    locales.forEach((key) => (cachedLocales[key] = true));
  }
  return cachedLocales;
}
開發者ID:Mercateo,項目名稱:ws,代碼行數:11,代碼來源:intl.ts

示例7: generateTypings

export async function generateTypings(
  declarationDir: string,
  filePatterns = sourceFilePatterns
) {
  if (project.typings) {
    debug('Generate typings.');
    const filePaths = await globby(filePatterns);
    const options = {
      declaration: true,
      declarationDir
    };

    const result = createProgram(filePaths, options).emit(
      undefined, // targetSourceFile
      undefined, // writeFile
      undefined, // cancellationToken
      true // emitOnlyDtsFiles
    );

    if (result.diagnostics.length) {
      const message = result.diagnostics
        .map(({ messageText, file, start }) => {
          if (file && start) {
            const pos = file.getLineAndCharacterOfPosition(start);
            const frame = codeFrame(
              file.getFullText(),
              pos.line + 1,
              pos.character + 1,
              {
                highlightCode: true
              }
            );
            return `${messageText}\n${frame}`;
          } else {
            return messageText;
          }
        })
        .join('\n');
      throw `\n${message}\n`;
    }

    // check if they exist at the same place where it is configured in your package.json
    const exist = await existsAsync(join(process.cwd(), project.typings));
    if (!exist) {
      throw `${red('typings')} do not exist in ${project.typings}`;
    }
  }
}
開發者ID:Mercateo,項目名稱:ws,代碼行數:48,代碼來源:typescript.ts

示例8: discoverModules

/**
 * Function to list plugins from a specific directory. The returned array consists of module names
 * relative to the passed-in directory.
 */
async function discoverModules(directory: string): Promise<string[]> {
  // Given the tree structure below, this function returns the array ['Foo', 'Bar', 'Baz']:
  // * plugins/
  //   * Foo/
  //   * Bar.js
  //   * Baz/
  //
  // Here's how:
  // 1. globby('*', cwd: plugins) => [Foo, Bar.js, Baz] (directories don't have suffixes)
  // 2. path.basename(module, .js) => [Foo, Bar, Baz] (extension in basename() is optional)
  //
  // We use path.basename() to prettify the module names. It's compatible with how require() sees
  // the world, as it will attempt to add the .js extension back before falling back to finding
  // an index.js file in the named directory. So long as the modules are given good names, they
  // can be presented to the user directly in a menu or printed out for debugging.
  const modules = await globby('*', { cwd: directory, onlyFiles: false });

  return modules.map(moduleName => path.basename(moduleName, '.js'));
}
開發者ID:forumone,項目名稱:generator-web-starter,代碼行數:23,代碼來源:discoverModules.ts

示例9: through

    files.forEach(filepath => {
        console.log(filepath);
        var bundledStream = through();
        var fileParts = filepath.split('/');
        var directory = fileParts.slice(0, fileParts.length - 1).join('/');
        var filename = fileParts[fileParts.length - 1].replace('.ts', '.out.js');

        if (filename == 'app.js')
            return;

        if (filename.indexOf('.out.out.') !== -1) {
            return;
        }

         console.log(`dir: ${directory} filename: ${filename}`);

        bundledStream
            .pipe(source(filename))
            .pipe(buffer())
            // .pipe(sm.init({loadMaps: true}))
            // .pipe(uglify())
            // .pipe(sm.write('./'))
            .pipe(gulp.dest(directory));

        globby(taskPath, function(err, entries) {
            if (err) {
                bundledStream.emit('error', err);
                return;
            }

            var b = browserify({
                entries: [filepath],
                debug: true,
                paths: ['scripts'],
                noParse:['lodash.js'],
                standalone: 'GLib'

            }).plugin('tsify',{target:'es5'});
            b.bundle().pipe(bundledStream);
        });
    });
開發者ID:cmc19,項目名稱:GutiarLibTS,代碼行數:41,代碼來源:gulpfile.ts


注:本文中的globby.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。