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


TypeScript fs-extra.rmdirSync函數代碼示例

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


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

示例1: cleanupOldScreenshots

function* cleanupOldScreenshots() {
  console.log("Cleaning up screenshots directory");
  try {
    fsa.emptyDirSync(SCREENSHOTS_DIRECTORY);
    fsa.rmdirSync(SCREENSHOTS_DIRECTORY);
  } catch(e) {
    console.warn(`Cannot cleaup directory ${SCREENSHOTS_DIRECTORY}: `, e);
  }

  fsa.mkdirpSync(SCREENSHOTS_DIRECTORY);
}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:11,代碼來源:screenshots.ts

示例2: function

var deleteFolderRecursive = function (path: string) {
    if (fs.existsSync(path)) {
        fs.readdirSync(path).forEach(function (file: string, index: number) {
            var curPath = path + "/" + file;
            if (fs.lstatSync(curPath).isDirectory()) { // recurse
                deleteFolderRecursive(curPath);
            } else { // delete file
                fs.unlinkSync(curPath);
            }
        });
        fs.rmdirSync(path);
    }
}
開發者ID:gitter-badger,項目名稱:nodulus,代碼行數:13,代碼來源:modules.ts

示例3: deleteFolderRecursive

var deleteFolderRecursive = (folderpath: string) => {
    if (fs.existsSync(folderpath)) {
        fs.readdirSync(folderpath).forEach((file: string, index: number) => {
            var curPath = path.join(folderpath, file);
            if (fs.lstatSync(curPath).isDirectory()) { // recurse
                deleteFolderRecursive(curPath);
            } else { // delete file
                fs.unlinkSync(curPath);
            }
        });
        fs.rmdirSync(path);
    }
}
開發者ID:nodulusteam,項目名稱:-nodulus-modules,代碼行數:13,代碼來源:modules.ts

示例4: emptyDirectory

 fs.readdirSync(dirPath).forEach(file => {
   const curPath = path.join(dirPath, file)
   if (fs.lstatSync(curPath).isDirectory()) {
     let removed = false
     let i = 0 // retry counter
     do {
       try {
         if (!opts.excludes.length || !opts.excludes.some(item => curPath.indexOf(item) >= 0)) {
           emptyDirectory(curPath)
           fs.rmdirSync(curPath)
         }
         removed = true
       } catch (e) {
       } finally {
         if (++i < retries) {
           continue
         }
       }
     } while (!removed)
   } else {
     fs.unlinkSync(curPath)
   }
 })
開發者ID:YangShaoQun,項目名稱:taro,代碼行數:23,代碼來源:index.ts

示例5: if


//.........這裏部分代碼省略.........
                  await compileDepStyles(outputWXSSPath, item.styles)
                  resolve()
                }, 300)
              })
            } else {
              await compileDepStyles(outputWXSSPath, item.styles)
            }

            let modifyOutput = outputWXSSPath.replace(appPath + path.sep, '')
            modifyOutput = modifyOutput.split(path.sep).join('/')
            Util.printLog(processTypeEnum.GENERATE, '樣式文件', modifyOutput)
          }))
        } else {
          let outputWXSSPath = filePath.replace(path.extname(filePath), outputFilesTypes.STYLE)
          let modifySource = outputWXSSPath.replace(appPath + path.sep, '')
          modifySource = modifySource.split(path.sep).join('/')
          Util.printLog(processTypeEnum.MODIFY, '樣式文件', modifySource)
          outputWXSSPath = outputWXSSPath.replace(sourceDir, outputDir)
          if (isWindows) {
            await new Promise((resolve, reject) => {
              setTimeout(async () => {
                await compileDepStyles(outputWXSSPath, [filePath])
                resolve()
              }, 300)
            })
          } else {
            await compileDepStyles(outputWXSSPath, [filePath])
          }
          let modifyOutput = outputWXSSPath.replace(appPath + path.sep, '')
          modifyOutput = modifyOutput.split(path.sep).join('/')
          Util.printLog(processTypeEnum.GENERATE, '樣式文件', modifyOutput)
        }
      } else {
        if (isCopyingFiles[outputFilePath]) return
        isCopyingFiles[outputFilePath] = true

        let modifyOutput = outputFilePath.replace(appPath + path.sep, '')
        modifyOutput = modifyOutput.split(path.sep).join('/')
        Util.printLog(processTypeEnum.COPY, '文件', modifyOutput)

        if (!fs.existsSync(filePath)) {
          let modifySrc = filePath.replace(appPath + path.sep, '')
          modifySrc = modifySrc.split(path.sep).join('/')
          Util.printLog(processTypeEnum.ERROR, '文件', `${modifySrc} 不存在`)
        } else {
          fs.ensureDir(path.dirname(outputFilePath))
          if (filePath === outputFilePath) {
            return
          }
          fs.copySync(filePath, outputFilePath)
        }
      }

      // 如果 output/plugin 裏有新編譯出的文件,
      // 先把 js 裏對 npm 的引用修改,然後把所有文件遷移到插件目錄
      // 最後刪除 output/plugin
      const names = glob.sync(`${outputDir}/${PLUGIN_ROOT}/**/*`)
      if (names.length) {
        const jsNames = glob.sync(`${outputDir}/${PLUGIN_ROOT}/{,!(npm)/**/}*.js`)
        const ioPromises = jsNames.map(async name => {
          const content = fs.readFileSync(name).toString()

          let isShouldBeWritten
          let replacement = content.replace(/['|"]((\.\.\/)+)npm\/.+?['|"]/g, (str, $1) => {
            isShouldBeWritten = true
            return $1 === '../' ? str.replace('../', './') : str.replace('../', '')
          })

          const REG_PLUGIN_DEPS = RegExp(`['|"](/${PLUGIN_ROOT}.+)['|"]`, 'g')
          replacement = replacement.replace(REG_PLUGIN_DEPS, (str, $1) => {
            if (REG_FONT.test($1) || REG_IMAGE.test($1) || REG_MEDIA.test($1)) {
              return str.replace(RegExp(`^['|"]/${PLUGIN_ROOT}`, 'g'), str => str.replace(`${PLUGIN_ROOT}`, ''))
            }
            return str
          })

          if (isShouldBeWritten) await fs.writeFile(name, replacement)
        })
        await Promise.all(ioPromises)

        await Promise.all(names.map(async from => {
          if (fs.existsSync(from) && fs.statSync(from).isFile()) {
            const to = from.replace(outputDir, appPath)
            fs.ensureDirSync(path.dirname(to))
            await fs.copyFile(from, to)
          }
        }))
        const tempPluginPath = path.join(outputDir, PLUGIN_ROOT)
        Util.emptyDirectory(tempPluginPath)
        fs.rmdirSync(tempPluginPath)
      }
      // 遷移 npm 到 plugin 目錄
      Util.emptyDirectory(path.join(pluginPath, NPM_DIR))
      // fs.rmdirSync(tempPluginPath)
      fs.copySync(path.join(outputDir, NPM_DIR), path.join(pluginPath, NPM_DIR))

      initCompileScripts()
      initCompileStyles()
      isCopyingFiles = {}
    })
開發者ID:YangShaoQun,項目名稱:taro,代碼行數:101,代碼來源:plugin.ts


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