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


TypeScript klaw類代碼示例

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


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

示例1: Promise

 return new Promise((resolve, reject) => {
   klaw(sourceDir)
     .on('data', file => {
       if (!file.stats.isDirectory()) {
         processFile(file.path)
       }
     })
     .on('end', () => {
       initProjectFile()
       if (!fs.existsSync(path.join(tempPath, 'node_modules'))) {
         console.log()
         console.log(chalk.yellow('開始安裝依賴~'))
         process.chdir(tempPath)
         let command
         if (Util.shouldUseYarn()) {
           command = 'yarn'
         } else if (Util.shouldUseCnpm()) {
           command = 'cnpm install'
         } else {
           command = 'npm install'
         }
         shelljs.exec(command, {silent: false})
       }
       resolve()
     })
 })
開發者ID:YangShaoQun,項目名稱:taro,代碼行數:26,代碼來源:rn.ts

示例2: convertToJDReact

export function convertToJDReact ({tempPath, entryBaseName}) {
  klaw(tempPath)
    .on('data', file => {
      const nativeBundlePath = path.join(tempPath, NATIVE_BUNDLES_DIR)
      if (file.stats.isDirectory() ||
        file.path.startsWith(path.join(tempPath, 'node_modules')) ||
        file.path.startsWith(nativeBundlePath) ||
        file.path.endsWith('yarn.lock') ||
        file.path.endsWith('package-lock.json')
      ) return

      processFile({filePath: file.path, tempPath, entryBaseName})
    })
    .on('end', () => {
      // copy templates under jsbundles/
      const templateSrcDirname = path.join(jdreactTmpDirname, 'template')
      const indexDistDirPath = path.join(jdreactPath, 'jsbundles')
      // not overwrite
      fs.copySync(path.join(templateSrcDirname, 'JDReact.version'), path.join(indexDistDirPath, `${moduleName}.version`), {overwrite: false})
      fs.copySync(path.join(templateSrcDirname, 'JDReact.web.js'), path.join(indexDistDirPath, `${moduleName}.web.js`), {overwrite: false})
      Util.printLog(processTypeEnum.COPY, 'templates', templateSrcDirname)
    })
}
開發者ID:YangShaoQun,項目名稱:taro,代碼行數:23,代碼來源:convert_to_jdreact.ts

示例3: require

import * as klaw from "klaw";
const path = require('path');

// README.md: Streams 1 (push) example:

let items: klaw.Item[] = [] // files, directories, symlinks, etc

klaw('/some/dir')
    .on('data', function(item: klaw.Item) {
        items.push(item)
    })
    .on('end', function() {
        console.dir(items) // => [ ... array of files]
    })

// README.md: Streams 2 & 3 (pull) with error handling

klaw('/some/dir')
    .on('readable', function() {
        let item: klaw.Item;
        while (item = this.read()) {
            items.push(item)
        }
    })
    .on('error', function(err: Error, item: klaw.Item) {
        console.log(err.message)
        console.log(item.path) // the file the error occurred on
    })
    .on('end', function() {
        console.log(items) // => [ ... array of files]
    })
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:klaw-tests.ts


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