当前位置: 首页>>代码示例>>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;未经允许,请勿转载。