• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fs-extra.ensureDir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中fs-extra.ensureDir函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ensureDir函数的具体用法?TypeScript ensureDir怎么用?TypeScript ensureDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ensureDir函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: copyFileToTaro

 copyFileToTaro (from: string, to: string, options?: fs.CopyOptionsSync) {
   const filename = path.basename(from)
   if (fs.statSync(from).isFile() && !path.extname(to)) {
     fs.ensureDir(to)
     return fs.copySync(from, path.join(to, filename), options)
   }
   fs.ensureDir(path.dirname(to))
   return fs.copySync(from, to, options)
 }
开发者ID:YangShaoQun,项目名称:taro,代码行数:9,代码来源:index.ts


示例2: reject

	return new Promise<FirefoxProfile>(async (resolve, reject) => {

		if (config.srcProfileDir) {

			FirefoxProfile.copy({
				profileDirectory: config.srcProfileDir,
				destinationDirectory: config.profileDir
			}, 
			(err, profile) => {
				if (err || !profile) {
					reject(err);
				} else {
					profile.shouldDeleteOnExit(false);
					resolve(profile);
				}
			});

		} else {

			await fs.ensureDir(config.profileDir);
			let profile = new FirefoxProfile({
				destinationDirectory: config.profileDir
			});
			profile.shouldDeleteOnExit(false);
			resolve(profile);
		}
	});
开发者ID:hbenl,项目名称:vscode-firefox-debug,代码行数:27,代码来源:launch.ts


示例3: shouldGenerateAssets

 shouldGenerateAssets(generator).then(res => {
     if (res) {
         fs.ensureDir(generator.vscodeFolder, err => {
             addAssets(generator, operations);
         });
     }
 });
开发者ID:rlugojr,项目名称:omnisharp-vscode,代码行数:7,代码来源:assets.ts


示例4: join

(async () => {
  const jsonDir = join(__dirname, "dist"),
        magGarden = new MagGarden();

  console.info("Starting to crawl MagGarden...");
  await magGarden.crawl();

  await ensureDir(jsonDir);
  await Promise.all([
    writeFile(join(jsonDir, "CNAME"), "api.comicstand.phanective.org"),
    writeFile(join(jsonDir, "comics.json"), JSON.stringify(magGarden.Magazines)),
  ]);

  return new Promise((resolve, reject) => {
    publish("dist", {
      repo: "[email protected]:phanect/static-comicstand-data.git",
    }, (err: Error) => {
      if (err) {
        reject(err);
      } else {
        resolve();
      }
    });
  });
})();
开发者ID:phanect,项目名称:ComicAlert,代码行数:25,代码来源:crawler.ts


示例5: updateFixture

async function updateFixture(options: UpdateFixtureOptions) {
  const fixturesDir =
      path.resolve(__dirname, '../../fixtures/packages/', options.folder);
  const sourceDir = path.join(fixturesDir, 'source');
  const convertedDir = path.join(fixturesDir, 'expected');

  if (!options.skipSourceUpdate) {
    const branch = options.branch || 'master';

    console.log(`Cloning ${options.repoUrl} #${branch} to ${sourceDir}...`);
    await fs.ensureDir(fixturesDir);
    await fs.remove(sourceDir);

    await exec(
        `git clone ${options.repoUrl} ${sourceDir} --branch=${
            branch} --depth=1`,
        {cwd: fixturesDir});
    await fs.remove(path.join(sourceDir, '.git'));
    await fs.remove(path.join(sourceDir, '.github'));
    await fs.remove(path.join(sourceDir, '.gitignore'));

    await overridePolymer(sourceDir);

    await exec('bower install', {cwd: sourceDir});
  }

  const testConfig = require(path.join(fixturesDir, 'test.js')) as TestConfig;
  await runFixture(sourceDir, convertedDir, testConfig);

  // Our integration tests always skip bower_components when comparing, so
  // there's no reason to check them into git.
  await fs.remove(path.join(convertedDir, 'bower_components'));

  console.log(`Done.`);
}
开发者ID:,项目名称:,代码行数:35,代码来源:


示例6: createApp

async function createApp(verbose: boolean, version: string) {
  checkAppName(appName)
  await fs.ensureDir(root)
  const isSafe = await isSafeToCreateProjectIn(root)
  if (!isSafe) {
    console.log(
      `The directory ${chalk.green(
        appName
      )} contains files that could conflict.`
    )
    console.log('Try using a new directory name.')
    process.exit(1)
  }

  console.log(`Creating a new React app in ${chalk.green(root)}.`)
  console.log()

  const packageJson = {
    name: appName,
    version: '0.1.0',
    private: true,
  }
  await fs.writeFile(
    path.join(root, 'package.json'),
    JSON.stringify(packageJson, null, 2)
  )
  process.chdir(root)

  await run(appName, version, verbose)
}
开发者ID:aranja,项目名称:tux,代码行数:30,代码来源:new.ts


示例7: AssetGenerator

            return this.checkWorkspaceInformationMatchesWorkspaceFolder(folder).then(async workspaceMatches => { 
                const generator = new AssetGenerator(info);
                if (workspaceMatches && containsDotNetCoreProjects(info)) {
                    const dotVscodeFolder: string = path.join(folder.uri.fsPath, '.vscode');
                    const tasksJsonPath: string = path.join(dotVscodeFolder, 'tasks.json');
                    
                    // Make sure .vscode folder exists, addTasksJsonIfNecessary will fail to create tasks.json if the folder does not exist. 
                    return fs.ensureDir(dotVscodeFolder).then(async () => {
                        // Check to see if tasks.json exists.
                        return fs.pathExists(tasksJsonPath);
                    }).then(async tasksJsonExists => {
                        // Enable addTasksJson if it does not exist.
                        return addTasksJsonIfNecessary(generator, {addTasksJson: !tasksJsonExists});
                    }).then(() => {
                        const isWebProject = generator.hasWebServerDependency();
                        const launchJson: string = generator.createLaunchJson(isWebProject);

                        // jsonc-parser's parse function parses a JSON string with comments into a JSON object. However, this removes the comments. 
                        return parse(launchJson);
                    });
                }
                
                // Error to be caught in the .catch() below to write default C# configurations
                throw new Error("Does not contain .NET Core projects.");
            });
开发者ID:gregg-miskelly,项目名称:omnisharp-vscode,代码行数:25,代码来源:configurationProvider.ts


示例8: printLog

 files.forEach(file => {
   let outputFilePath
   if (NODE_MODULES_REG.test(file)) {
     outputFilePath = file.replace(nodeModulesPath, npmOutputDir)
   } else {
     outputFilePath = file.replace(sourceDir, outputDir)
   }
   if (isCopyingFiles.get(outputFilePath)) {
     return
   }
   isCopyingFiles.set(outputFilePath, true)
   let modifySrc = file.replace(appPath + path.sep, '')
   modifySrc = modifySrc.split(path.sep).join('/')
   let modifyOutput = outputFilePath.replace(appPath + path.sep, '')
   modifyOutput = modifyOutput.split(path.sep).join('/')
   printLog(processTypeEnum.COPY, '文件', modifyOutput)
   if (!fs.existsSync(file)) {
     printLog(processTypeEnum.ERROR, '文件', `${modifySrc} 不存在`)
   } else {
     fs.ensureDir(path.dirname(outputFilePath))
     if (file === outputFilePath) {
       return
     }
     if (cb) {
       cb(file, outputFilePath)
     } else {
       fs.copySync(file, outputFilePath)
     }
   }
 })
开发者ID:YangShaoQun,项目名称:taro,代码行数:30,代码来源:helper.ts


示例9: checkEnv

  async checkEnv () {
    this.emit('progress', 'checkJava')
    await this._checkJava()
    this.emit('progress', 'cleanNatives')
    await this._cleanNatives()
    this._arguments.push(`-Djava.library.path=${this._nativesPath}`)
    this.emit('progress', 'resolveLibraries')
    await this._setupLibraries()
    this.emit('progress', 'resolveNatives')
    await fs.mkdir(this._nativesPath)
    await this._setupNatives()
    if (this._missingLibrary.length !== 0) {
      this.emit('missing_all', this._missingLibrary)
      let err = new Error('missing library')
      err['missing'] = this._missingLibrary
      err['launcher'] = this
      throw err
    }

    await fs.ensureDir(this._gameDirectory)
    this.emit('progress', 'mergeArguments')
    this._arguments.push(this.opts.json['mainClass'])
    this._mcArguments()
    this.emit('progress', 'envOK')
  }
开发者ID:bangbang93,项目名称:BMCLJS,代码行数:25,代码来源:launcher.ts


示例10: withAfterEach

 withAfterEach(async t => {
   await fse.ensureDir('out');
   const { stderr } = shell.exec('node dist/src/cp-cli test/assets out');
   t.equal(stderr, '');
   const stats = fse.statSync('out/foo.txt');
   t.true(stats.isFile());
 }),
开发者ID:screendriver,项目名称:cp-cli,代码行数:7,代码来源:cp-cli.test.ts



注:本文中的fs-extra.ensureDir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra.ensureDirSync函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra.emptyDirSync函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap