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


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

本文整理匯總了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;未經允許,請勿轉載。