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


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

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


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

示例1: parseData

							child.on('close', (code: number) => {
								if (errorLine.trim().length > 0) {
									if (errorData) {
										parseData(errorLine.trim());
									}
									else {
										log.error(errorLine.trim());
									}
								}

								if (code === 0) {
									if (this.type !== 'metal' || this.platform === Platform.Krom) {
										if (compiledShader.files === null || compiledShader.files.length === 0) {
											fs.renameSync(temp, to);
										}
										for (let file of compiledShader.files) {
											fs.renameSync(path.join(this.to, file + '.temp'), path.join(this.to, file));
										}
									}
									resolve(compiledShader);
								}
								else {
									process.exitCode = 1;
									reject('Shader compiler error.');
								}
							});
開發者ID:KTXSoftware,項目名稱:khamake,代碼行數:26,代碼來源:ShaderCompiler.ts

示例2: setupFixtureRepository

export function setupFixtureRepository(repositoryName: string): string {
  const testRepoFixturePath = Path.join(__dirname, 'fixtures', repositoryName)
  const testRepoPath = temp.mkdirSync('desktop-git-test-')
  FSE.copySync(testRepoFixturePath, testRepoPath)

  FSE.renameSync(
    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'
  )

  submodules.forEach(entry => {
    const directory = Path.dirname(entry.path)
    const newPath = Path.join(directory, '.git')
    FSE.renameSync(entry.path, newPath)
  })

  return testRepoPath
}
開發者ID:Aj-ajaam,項目名稱:desktop,代碼行數:29,代碼來源:fixture-helper.ts

示例3: rename

export function rename(src: string, dest: string) {
    // Log.info(`./> mv ${src} ${dest}`);
    try {
        fse.renameSync(src, dest);
    } catch (e) {
        Log.error(`rename: ${e.message}`);
    }
}
開發者ID:VestaRayanAfzar,項目名稱:vesta,代碼行數:8,代碼來源:FsUtil.ts

示例4: catch

 .forEach(file => {
   if (file.endsWith(oldExtension)) {
     try {
       fs.renameSync(file, file.replace(oldExtension, newExtension));
     } catch (error) {
       logger.error(`Failed to rename log file: "${error.message}"`);
     }
   }
 });
開發者ID:wireapp,項目名稱:wire-desktop,代碼行數:9,代碼來源:main.ts

示例5: parseData

						child.on('close', (code: number) => {
							if (errorLine.trim().length > 0) {
								if (errorData) {
									parseData(errorLine.trim());
								}
								else {
									log.error(errorLine.trim());
								}
							}

							if (code === 0) {
								fs.renameSync(temp, to);
								resolve(compiledShader);
							}
							else {
								process.exitCode = 1;
								reject('Shader compiler error.');
							}
						});
開發者ID:jefvel,項目名稱:khamake,代碼行數:19,代碼來源:ShaderCompiler.ts

示例6: resolve

		process.on('close', (code) => {
			if (code !== 0) {
				log.error('kraffiti process exited with code ' + code + ' when trying to convert ' + path.parse(from).name);
				resolve();
				return;
			}

			fs.renameSync(temp, to);
			
			const lines = output.split('\n');
			for (let line of lines) {
				if (line.startsWith('#')) {
					var numbers = line.substring(1).split('x');
					options.original_width = parseInt(numbers[0]);
					options.original_height = parseInt(numbers[1]);
					resolve();
					return;
				}
			}
			resolve();
		});
開發者ID:hammeron-art,項目名稱:khamake,代碼行數:21,代碼來源:ImageTool.ts

示例7: asyncMap

  return await asyncMap(rawImages, (path) => {
    let parts = path.split('.');
    let newPath = "";
    let extension = parts[path.split('.').length -1];
    if (jpgExtensions.indexOf(extension) > -1) {
      parts[path.split('.').length - 1] = 'jpg';
      newPath = parts.join('.');
    } else {
      parts[path.split('.').length - 1] = 'png';
      newPath = parts.join('.');
    }
    if (path !== newPath) {
      let toReturn = newPath;
      path = resolve(basePath, path);
      newPath = resolve(basePath, newPath);
      logger.info(`Renaming ${path} to ${newPath}`);

      renameSync(path, newPath);

      return toReturn;
    } else {
      return path;
    }
  });
開發者ID:tbtimes,項目名稱:ledeTwo,代碼行數:24,代碼來源:imageCommand.ts

示例8:

 submodules.forEach(entry => {
   const directory = Path.dirname(entry.path)
   const newPath = Path.join(directory, '.git')
   FSE.renameSync(entry.path, newPath)
 })
開發者ID:Aj-ajaam,項目名稱:desktop,代碼行數:5,代碼來源:fixture-helper.ts

示例9:

});
fs.ensureSymlink(path, errorCallback);
fs.ensureSymlinkSync(path);
fs.emptyDir(path).then(() => {
	// stub
});
fs.emptyDir(path, errorCallback);
fs.emptyDirSync(path);
fs.pathExists(path).then((_exist: boolean) => {
	// stub
});
fs.pathExists(path, (_err: Error, _exists: boolean) => { });
const x: boolean = fs.pathExistsSync(path);

fs.rename(src, dest, errorCallback);
fs.renameSync(src, dest);
fs.truncate(path, len, errorCallback);
fs.truncateSync(path, len);
fs.chown(path, uid, gid, errorCallback);
fs.chownSync(path, uid, gid);
fs.fchown(fd, uid, gid, errorCallback);
fs.fchownSync(fd, uid, gid);
fs.lchown(path, uid, gid, errorCallback);
fs.lchownSync(path, uid, gid);
fs.chmod(path, modeNum, errorCallback);
fs.chmod(path, modeStr, errorCallback);
fs.chmodSync(path, modeNum);
fs.chmodSync(path, modeStr);
fs.fchmod(fd, modeNum, errorCallback);
fs.fchmod(fd, modeStr, errorCallback);
fs.fchmodSync(fd, modeNum);
開發者ID:gilamran,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:fs-extra-tests.ts

示例10: pack

    pack(module_name: string, callback: Function) {
        var baseFolder = global.clientAppRoot + "\\modules\\" + module_name + "\\";
        var manifest_file = fs.readJsonSync(baseFolder + consts.MANIFEST_NAME, { throws: false });
        //merge the manifest into the modules.json file
        if (manifest_file === null)
            callback("invalid json, try using ascii file");


        var zip = new JSZip();
        var filesArr: Array<any> = [];
        for (var i = 0; i < manifest_file.files.length; i++) {
            if (fs.existsSync(baseFolder + manifest_file.files[i])) {
                var fileContent = fs.readFileSync(baseFolder + manifest_file.files[i]);
                zip.file(manifest_file.files[i], fileContent);


            }


        }

        if (manifest_file.routes !== undefined) {
            var routeBase: string = serverRoot + "/routes/";
            for (var i = 0; i < manifest_file.routes.length; i++) {
                if (fs.existsSync(routeBase + manifest_file.routes[i].path)) {
                    var fileContent = fs.readFileSync(routeBase + manifest_file.routes[i].path);
                    zip.folder("routes").file(manifest_file.routes[i].path, fileContent);
                }

                var tsfile = routeBase + manifest_file.routes[i].path.replace('.js', '.ts');
                if (fs.existsSync(tsfile)) {
                    var fileContent = fs.readFileSync(tsfile);
                    zip.folder("routes").file(manifest_file.routes[i].path.replace('.js', '.ts'), fileContent);
                }


            }
        }


        if (manifest_file.scripts !== undefined) {
            for (var i = 0; i < manifest_file.scripts.length; i++) {
                if (fs.existsSync(baseFolder + "/scripts/" + manifest_file.scripts[i])) {
                    var fileContent = fs.readFileSync(baseFolder + "/scripts/" + manifest_file.scripts[i]);
                    zip.folder("scripts").file(manifest_file.scripts[i], fileContent);
                }
            }
        }





        if (fs.existsSync(baseFolder + "about.html")) {
            var fileContent = fs.readFileSync(baseFolder + "about.html");
            zip.file("about.html", fileContent);
        }




        var manifestContent = fs.readFileSync(baseFolder + consts.MANIFEST_NAME);
        zip.file(consts.MANIFEST_NAME, manifestContent);


        var content = zip.generate({ type: "nodebuffer" });
        var packageFileName = appRoot + "/nodulus_modules/" + module_name + ".zip";
        var packageBackupFileName = appRoot + "/nodulus_modules/" + module_name + "/" + module_name + "." + this.timestamp() + ".zip";

        if (fs.existsSync(packageFileName)) {
            fs.ensureDirSync(appRoot + "/nodulus_modules/" + module_name);
            fs.renameSync(packageFileName, packageBackupFileName);
        }
    
    
        //var oldPackage  = fs.readFileSync(global.appRoot + "/nodulus_modules/" + module_name + ".zip");
    
        // see FileSaver.js
        fs.writeFile(packageFileName, content, function (err: any) {
            if (err) throw err;
            callback(null, manifest_file);
        });



    }
開發者ID:gitter-badger,項目名稱:nodulus,代碼行數:86,代碼來源:modules.ts


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