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


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

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


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

示例1: storeTestCoverage

/**
 * Stores the test coverage data before running the next test that would overwrite it
 */
async function storeTestCoverage() {
  const outputPath = path.join(process.cwd(), '.nyc_output')
  try {
    await fs.stat(outputPath)
  } catch (e) {
    return
  }
  await fs.move(outputPath, path.join(process.cwd(), '.nyc_output_cli', uuid()))
}
開發者ID:Originate,項目名稱:tutorial-runner,代碼行數:12,代碼來源:world.ts

示例2: beforeEach

 beforeEach(async () => {
   makeStub.returns(fakeMake('darwin'));
   const dryPath = path.resolve(dir, 'out', 'publish-dry-run');
   await fs.mkdirs(dryPath);
   await fs.writeFile(path.resolve(dryPath, 'hash.json'), 'test');
   await publish({
     dir,
     interactive: false,
     dryRun: true,
   });
   expect(await fs.pathExists(path.resolve(dryPath, 'hash.json'))).to.equal(false, 'previous hashes should be erased');
   const backupDir = path.resolve(dir, 'out', 'backup');
   await fs.move(dryPath, backupDir);
   makeStub.returns(fakeMake('win32'));
   await publish({
     dir,
     interactive: false,
     dryRun: true,
   });
   for (const backedUp of await fs.readdir(backupDir)) {
     await fs.copy(path.resolve(backupDir, backedUp), path.resolve(dryPath, backedUp));
   }
 });
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:23,代碼來源:publish_spec.ts

示例3:

const uid = 0;
const gid = 0;
const fd = 0;
const modeNum = 0;
const modeStr = "";
const object = {};
const errorCallback = (err: Error) => { };
const readOptions: fs.ReadOptions = {
	reviver: {}
};
const writeOptions: fs.WriteOptions = {
	replacer: {}
};

fs.moveSync(src, dest, {});
fs.move(src, dest, {}).then(() => {
	// stub
});
fs.move(src, dest).then(() => {
	// stub
});
fs.move(src, dest, {}, () => {
	// stub
});
fs.move(src, dest, () => {
	// stub
});

fs.copy(src, dest).then(() => {
	// stub
});
開發者ID:gilamran,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:fs-extra-tests.ts

示例4: moveDirectory

export function moveDirectory(from: string, to: string) {
  return fs.move(from, to, { overwrite: true });
}
開發者ID:DevIntent,項目名稱:angular-cli,代碼行數:3,代碼來源:fs.ts

示例5: doWork

async function doWork() {
    try {
        tl.setResourcePath(path.join(__dirname, 'task.json'));

        const serverEndpoint: string = tl.getInput('serverEndpoint', true);
        const serverEndpointUrl: string = tl.getEndpointUrl(serverEndpoint, false);
        const username: string = tl.getEndpointAuthorizationParameter(serverEndpoint, 'username', false);
        const password: string = tl.getEndpointAuthorizationParameter(serverEndpoint, 'password', false);

        const jobName: string = tl.getInput('jobName', true);
        const localPathRoot: string = tl.getPathInput('saveTo', true);
        const itemPattern: string = tl.getInput('itemPattern', false) || "**";
        const strictSSL: boolean = ('true' !== tl.getEndpointDataParameter(serverEndpoint, 'acceptUntrustedCerts', true));

        let jenkinsClient: JenkinsRestClient = new JenkinsRestClient();
        let jenkinsJobDetails: JenkinsJobDetails;

        if (tl.getBoolInput('propagatedArtifacts') == true) {
            var artifactProvider = tl.getInput('artifactProvider');
            switch (artifactProvider.toLowerCase()) {
                case "azurestorage":
                    let azureDownloader = new AzureStorageArtifactDownloader(tl.getInput('ConnectedServiceNameARM', true),
                        tl.getInput('storageAccountName', true),
                        tl.getInput('containerName', true),
                        tl.getInput('commonVirtualPath', false));
                    await azureDownloader.downloadArtifacts(localPathRoot, tl.getInput('itemPattern', false) || "**");
                    break;
                default:
                    throw Error(tl.loc('ArtifactProviderNotSupported', artifactProvider));
            }
        }
        else {
            jenkinsJobDetails = await jenkinsClient.GetJobDetails();
            console.log(tl.loc("FoundJenkinsJobDetails", jenkinsJobDetails.jobName, jenkinsJobDetails.jobType, jenkinsJobDetails.buildId, jenkinsJobDetails.multiBranchPipelineName));

            const artifactQueryUrl: string = `${serverEndpointUrl}/${jenkinsJobDetails.jobUrlInfix}/${jenkinsJobDetails.multiBranchPipelineUrlInfix}/${jenkinsJobDetails.buildId}/api/json?tree=artifacts[*]`;
            var variables = {
                "endpoint": {
                    "url": serverEndpointUrl
                },
                "jobUrlInfix": jenkinsJobDetails.jobUrlInfix,
                "multibranchPipelineUrlInfix": jenkinsJobDetails.multiBranchPipelineUrlInfix,
                "version": jenkinsJobDetails.buildId
            };

            var handler = new handlers.BasicCredentialHandler(username, password);
            var hasArtifacts = await jenkinsClient.HasAssociatedArtifacts(artifactQueryUrl);

            if (hasArtifacts) {
                if (!itemPattern || itemPattern === '**') {
                    const archiveUrl: string = `${serverEndpointUrl}/${jenkinsJobDetails.jobUrlInfix}/${jenkinsJobDetails.multiBranchPipelineUrlInfix}/${jenkinsJobDetails.buildId}/artifact/*zip*/`
                    var zipLocation = path.join(localPathRoot, "archive.zip");
                    await getZipFromUrl(archiveUrl, strictSSL, zipLocation, handler);

                    var unzipPromise = unzip(zipLocation, localPathRoot);
                    unzipPromise.catch((error) => {
                        throw error;
                    });

                    await unzipPromise;

                    if (tl.exist(zipLocation)) {
                        tl.rmRF(zipLocation);
                    }

                    var archivePath = path.join(localPathRoot, "archive");
                    var tempPath = path.join(localPathRoot, uuidv4());
                    fsExtra.move(archivePath, tempPath)
                        .then(() => {
                            fsExtra.copy(tempPath, localPathRoot)
                                .then(() => {
                                    fsExtra.remove(tempPath).catch((error) => {
                                        throw error;
                                    });
                                })
                                .catch((error) => {
                                    throw error;
                                });
                        })
                        .catch((error) => {
                            throw error;
                        });
                }
                else {
                    await getArtifactsFromUrl(artifactQueryUrl, strictSSL, localPathRoot, itemPattern, handler, variables);
                }
            }
            else {
               console.log(tl.loc('NoAssociatedArtifacts'));
            }
        }

        console.log(tl.loc('ArtifactSuccessfullyDownloaded', localPathRoot));

        let downloadCommitsAndWorkItems: boolean = tl.getBoolInput("downloadCommitsAndWorkItems", false);
        if (downloadCommitsAndWorkItems) {
            if (tl.getBoolInput('propagatedArtifacts') == true) {
                try {
                    jenkinsJobDetails = await jenkinsClient.GetJobDetails();
                    console.log(tl.loc("FoundJenkinsJobDetails", jenkinsJobDetails.jobName, jenkinsJobDetails.jobType, jenkinsJobDetails.buildId, jenkinsJobDetails.multiBranchPipelineName));
//.........這裏部分代碼省略.........
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:101,代碼來源:jenkinsdownloadartifacts.ts

示例6: renameFile

 renameFile(oldFileName: string, newFileName: string): Observable<void> {
     return from(move(oldFileName, newFileName, { overwrite: false }))
         .pipe(enterZone(this.ngZone));
 }
開發者ID:suiruiw,項目名稱:geeks-diary,代碼行數:4,代碼來源:fs.service.ts


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