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

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

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

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



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

示例1: getNewPath

        getNewPath('Enter a new name', data.cwd, newPath => {
            fs.rename(file.path, newPath, err => {
                if (codeFileNav.checkError(err)) { return; }

                codeFileNav.showFileList();
            });
        });
开发者ID:jakelucas,项目名称:code-file-nav,代码行数:7,代码来源:commands.ts


示例2: clearNodeModules

async function clearNodeModules(): Promise<void> {
    const logger = getLogger();
    if (isRsyncModeEnabled) {
        return;
    }

    logger.trace(`moving node_modules to node_modules.bak.0`);

    let bodyCount = 0;
    let bakDirname;
    while (true) {
        bakDirname = `${nodeModules}.bak.${bodyCount}`;
        logger.trace(`moving node_modules to ${bakDirname}`);
        try {
            await fsExtra.stat(bakDirname);
            logger.trace(`${bakDirname} already exists; incrementing`);
            bodyCount++;
        } catch (err) {
            if (err.code && err.code === 'ENOENT') {
                await fsExtra.rename(nodeModules, bakDirname);
                logger.trace(`move was successful; removing ${bakDirname} without blocking`);
                return fsExtra.remove(bakDirname);
            }
        }
    }
}
开发者ID:mutantcornholio,项目名称:veendor,代码行数:26,代码来源:index.ts


示例3: reject

 return new Promise<void>((resolve, reject) => {
   fs.rename(from, to, (err) => {
     if (err) {
       reject(err);
     } else {
       resolve();
     }
   });
 });
开发者ID:3L4CKD4RK,项目名称:angular-cli,代码行数:9,代码来源:fs.ts


示例4: cleanAsync

async function cleanAsync(series: mio.IScraperSeries) {
  let chapterPaths = series.chapters.map(seriesChapter => shared.path.normal(series.providerName, series.title, seriesChapter.name + shared.extension.cbz));
  let fileNames = await fs.readdir(shared.path.normal(series.providerName, series.title));
  let filePaths = fileNames.map(fileName => shared.path.normal(series.providerName, series.title, fileName));
  for (let filePath of filePaths) {
    let fileExtension = path.extname(filePath);
    if (fileExtension === shared.extension.cbz && chapterPaths.indexOf(filePath) === -1) {
      await fs.rename(filePath, filePath.substr(0, filePath.length - fileExtension.length) + shared.extension.del);
    }
  }
}
开发者ID:Deathspike,项目名称:mangarack,代码行数:11,代码来源:download.ts


示例5: function

 fs.stat(newPath, function (err, stats) {
     if (err && err.code === "ENOENT") {
         return fs.rename(oldPath, newPath, callback);
     }
     if (err) {
         return callback(err);
     }
     err = new Error("EEXIST: file already exists: " + newPath);
     err.code = "EEXIST";
     callback(err);
 });
开发者ID:zaggino,项目名称:brackets-electron,代码行数:11,代码来源:fs-additions.ts


示例6: archiveAsync

 await mio.usingAsync(seriesChapter.iteratorAsync(), async iterator => {
   try {
     await archiveAsync(chapter, iterator);
     chapter.finalize();
     await fs.rename(chapterPath + shared.extension.tmp, chapterPath);
     console.log(`Finished ${seriesChapter.name} (${timer})`);
   } catch (error) {
     await fs.unlink(chapterPath + shared.extension.tmp);
     throw error;
   } finally {
     chapter.abort();
   }
 });
开发者ID:Deathspike,项目名称:mangarack,代码行数:13,代码来源:download.ts


示例7: setupFixtureRepository

export async function setupFixtureRepository(
  repositoryName: string
): Promise<string> {
  const testRepoFixturePath = Path.join(
    __dirname,
    '..',
    'fixtures',
    repositoryName
  )
  const testRepoPath = _temp.mkdirSync('desktop-git-test-')
  await FSE.copy(testRepoFixturePath, testRepoPath)

  await FSE.rename(
    Path.join(testRepoPath, '_git'),
    Path.join(testRepoPath, '.git')
  )

  const ignoreHiddenFiles = function(item: KlawEntry) {
    const basename = Path.basename(item.path)
    return basename === '.' || basename[0] !== '.'
  }

  const entries: ReadonlyArray<KlawEntry> = klawSync(testRepoPath)
  const visiblePaths = entries.filter(ignoreHiddenFiles)
  const submodules = visiblePaths.filter(
    entry => Path.basename(entry.path) === '_git'
  )

  for (const submodule of submodules) {
    const directory = Path.dirname(submodule.path)
    const newPath = Path.join(directory, '.git')
    await FSE.rename(submodule.path, newPath)
  }

  return testRepoPath
}
开发者ID:ghmoore,项目名称:desktop,代码行数:36,代码来源:repositories.ts


示例8: reject

			return new this.$q<Models.IDocument>((resolve, reject) => {

				if (!fs.existsSync(oldPath)) {
					reject("Document does not exist");
					return;
				}

				if (fs.existsSync(document.path)) {
					reject("New filename already exists");
					return;
				}

				fs.rename(oldPath, document.path, (err) => {
					if (err) {
						reject(err);
					}
					else {
						resolve(document);
					}
				});
			});
开发者ID:bihai,项目名称:Notedown,代码行数:21,代码来源:DocumentService.ts


示例9: reject

			return new this.$q<Models.IFolder>((resolve, reject) => {
				if (!nodeFs.existsSync(folder.path)) {
					reject("Folder does not exist");
					return;
				}

				var parentPath = nodePath.dirname(folder.path);
				var newPath = nodePath.join(parentPath, name);

				if (nodeFs.existsSync(newPath)) {
					reject("Folder with name " + name + " already exists");
					return;
				}

				nodeFs.rename(folder.path, newPath, (err) => {
					if (err) {
						reject(err);
					}
					else {
						resolve(new Models.NodeFolder(newPath));
					}
				});
			});
开发者ID:bihai,项目名称:Notedown,代码行数:23,代码来源:FolderService.ts


示例10: downloadSdk

export default async function downloadSdk() {
  const alreadyDownloaded = await fs.pathExistsSync(SDK_DIR);
  if (alreadyDownloaded) {
    console.log('VK iOS SDK already downloaded');
    return;
  }

  console.log(`Downloading VK iOS SDK as ${SDK_ZIP}`);
  const response = await axios.get(`https://api.github.com/repos/VKCOM/vk-ios-sdk/releases`);
  const data: GithubRelease[] = response.data;
  const zip = await axios.get(data[0].zipball_url, { responseType: 'arraybuffer' });
  await fs.writeFile(SDK_ZIP, zip.data);

  let sdkDir = '';

  console.log(`\nExtracting VK iOS SDK to ${SDK_DIR}`);
  try {
    await extract(
      SDK_ZIP,
      {
        onEntry: (entry: any) => sdkDir = sdkDir || entry.fileName,
        dir: process.cwd(),
      },
    );
    await fs.rename(sdkDir, SDK_DIR);
    console.log('\nDone\n');
  } catch (err) {
    console.warn(`Failed to download and extract VK iOS SDK: ${err}`);
  } finally {
      try {
        await fs.remove(SDK_ZIP);
      } catch (e) {
        console.warn('Failed to unlink some temporary/unnecessary files');
      }
  }
}
开发者ID:doomsower,项目名称:react-native-vkontakte-login,代码行数:36,代码来源:postinstall.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra.renameSync函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra.removeSync函数代码示例发布时间: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