export async function cacheDir()

in tool.ts [294:321]


export async function cacheDir(sourceDir: string,
    tool: string,
    version: string,
    arch?: string): Promise<string> {
    version = semver.clean(version);
    arch = arch || os.arch();
    console.log(tl.loc('TOOL_LIB_CachingTool', tool, version, arch));

    tl.debug('source dir: ' + sourceDir);
    if (!tl.stats(sourceDir).isDirectory()) {
        throw new Error('sourceDir is not a directory');
    }

    // create the tool dir
    let destPath: string = _createToolPath(tool, version, arch);

    // copy each child item. do not move. move can fail on Windows
    // due to anti-virus software having an open handle on a file.
    for (let itemName of fs.readdirSync(sourceDir)) {
        let s = path.join(sourceDir, itemName);
        tl.cp(s, destPath + '/', '-r');
    }

    // write .complete
    _completeToolPath(tool, version, arch);

    return destPath;
}