本文整理匯總了TypeScript中os.arch函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript arch函數的具體用法?TypeScript arch怎麽用?TypeScript arch使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了arch函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: acquireNodeFromFallbackLocation
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
// In this case, there will be two files located at:
// /dist/v5.10.1/win-x64/node.exe
// /dist/v5.10.1/win-x64/node.lib
// If this is not the structure, there may also be two files located at:
// /dist/v0.12.18/node.exe
// /dist/v0.12.18/node.lib
// This method attempts to download and cache the resources from these alternative locations.
// Note also that the files are normally zipped but in this case they are just an exe
// and lib file in a folder, not zipped.
async function acquireNodeFromFallbackLocation(version: string): Promise<string> {
// Create temporary folder to download in to
let tempDownloadFolder: string = 'temp_' + Math.floor(Math.random() * 2000000000);
let tempDir: string = path.join(taskLib.getVariable('agent.tempDirectory'), tempDownloadFolder);
taskLib.mkdirP(tempDir);
let exeUrl: string;
let libUrl: string;
try {
exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
}
catch (err) {
if (err['httpStatusCode'] &&
err['httpStatusCode'] === '404')
{
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
}
else {
throw err;
}
}
return await toolLib.cacheDir(tempDir, 'node', version);
}
示例2: sys
export function sys() {
if (os.platform() === 'linux') {
if (os.arch() === 'arm') return '-linuxarm';
else if (os.arch() === 'x64') return '-linux64';
else return '-linux32';
}
else if (os.platform() === 'win32') {
return '.exe';
}
else {
return '-osx';
}
}
示例3: acquireNodeFromFallbackLocation
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
// In this case, there will be two files located at:
// /dist/v5.10.1/win-x64/node.exe
// /dist/v5.10.1/win-x64/node.lib
// This method attempts to download and cache the resources from this alternative location.
// Note also that the files are normally zipped but in this case they are just an exe
// and lib file in a folder, not zipped.
async function acquireNodeFromFallbackLocation(version: string): Promise<string> {
let exeUrl: string = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
let libUrl: string = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
// Create temporary folder to download in to
let tempDownloadFolder: string = 'temp_' + Math.floor(Math.random() * 2000000000);
let tempDir: string = path.join(taskLib.getVariable('agent.tempDirectory'), tempDownloadFolder);
taskLib.mkdirP(tempDir);
let exeDownloadPath: string = await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
let libDownloadPath: string = await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
return await toolLib.cacheDir(tempDir, 'node', version);
}
示例4: downloadBinary
/**
* Download the binary file.
* @param binary The binary of interest.
* @param outputDir The directory where files are downloaded and stored.
* @param opt_proxy The proxy for downloading files.
* @param opt_ignoreSSL To ignore SSL.
* @param opt_callback Callback method to be executed after the file is downloaded.
*/
static downloadBinary(
binary: Binary, outputDir: string, opt_proxy?: string,
opt_ignoreSSL?: boolean, opt_callback?: Function): void {
logger.info(binary.name + ': downloading version ' + binary.version());
var url = binary.url(os.type(), os.arch());
if (!url) {
logger.error(binary.name + ' v' + binary.version() + ' is not available for your system.');
return;
}
Downloader.httpGetFile_(
url, binary.filename(os.type(), os.arch()), outputDir, opt_proxy, opt_ignoreSSL, (filePath: string) => {
if (opt_callback) {
opt_callback(binary, outputDir, filePath);
}
});
}
示例5: machineId
return machineId().catch(() => {
// In case MachineId fails
const hash = crypto.createHash('sha256')
const network = os.networkInterfaces()
hash.update(os.arch() + os.hostname() + os.platform() + os.type() + network['mac'])
return hash.digest('hex')
})
示例6: register
register("package", async (runner, releaseTag) => {
if (!releaseTag) {
throw new Error("Please specify the release tag.");
}
const releasePath = path.resolve(__dirname, "../release");
const archiveName = `code-server-${releaseTag}-${os.platform()}-${os.arch()}`;
const archiveDir = path.join(releasePath, archiveName);
fse.removeSync(archiveDir);
fse.mkdirpSync(archiveDir);
const binaryPath = path.join(__dirname, `../packages/server/cli-${os.platform()}-${os.arch()}`);
const binaryDestination = path.join(archiveDir, "code-server");
fse.copySync(binaryPath, binaryDestination);
fs.chmodSync(binaryDestination, "755");
["README.md", "LICENSE"].forEach((fileName) => {
fse.copySync(path.resolve(__dirname, `../${fileName}`), path.join(archiveDir, fileName));
});
runner.cwd = releasePath;
await os.platform() === "linux"
? runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`])
: runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]);
});
示例7: update
/**
* Parses the options and downloads binaries if they do not exist.
* @param options
*/
function update(options: Options): void {
let standalone = options[Opt.STANDALONE].getBoolean();
let chrome = options[Opt.CHROME].getBoolean();
let ie: boolean = false;
let ie32: boolean = false;
if (options[Opt.IE]) {
ie = options[Opt.IE].getBoolean();
}
if (options[Opt.IE32]) {
ie32 = options[Opt.IE32].getBoolean();
}
let outputDir = Config.getSeleniumDir();
if (options[Opt.OUT_DIR].getString()) {
if (path.isAbsolute(options[Opt.OUT_DIR].getString())) {
outputDir = options[Opt.OUT_DIR].getString();
} else {
outputDir = path.resolve(Config.getBaseDir(), options[Opt.OUT_DIR].getString());
}
FileManager.makeOutputDirectory(outputDir);
}
let ignoreSSL = options[Opt.IGNORE_SSL].getBoolean();
let proxy = options[Opt.PROXY].getString();
// setup versions for binaries
let binaries = FileManager.setupBinaries();
binaries[StandAlone.id].versionCustom = options[Opt.VERSIONS_STANDALONE].getString();
binaries[ChromeDriver.id].versionCustom = options[Opt.VERSIONS_CHROME].getString();
if (options[Opt.VERSIONS_IE]) {
binaries[IEDriver.id].versionCustom = options[Opt.VERSIONS_IE].getString();
}
// if the file has not been completely downloaded, download it
// else if the file has already been downloaded, unzip the file, rename it, and give it permissions
if (standalone) {
let binary = binaries[StandAlone.id];
FileManager.toDownload(binary, outputDir).then((value: boolean) => {
if (value) {
Downloader.downloadBinary(binary, outputDir);
} else {
logger.info(binary.name + ': file exists ' + path.resolve(outputDir, binary.filename(os.type(), os.arch())));
logger.info(binary.name + ': v' + binary.versionCustom + ' up to date');
}
});
}
if (chrome) {
let binary = binaries[ChromeDriver.id];
updateBinary(binary, outputDir, proxy, ignoreSSL);
}
if (ie) {
let binary = binaries[IEDriver.id];
binary.arch = os.arch(); // Win32 or x64
updateBinary(binary, outputDir, proxy, ignoreSSL);
}
if (ie32) {
let binary = binaries[IEDriver.id];
binary.arch = 'Win32';
updateBinary(binary, outputDir, proxy, ignoreSSL);
}
}
示例8:
handler: () => ({
hostname: os.hostname(),
arch: os.arch(),
platfoirm: os.platform(),
cpus: os.cpus().length,
totalmem: humanize.filesize(os.totalmem()),
networkInterfaces: os.networkInterfaces()
})
示例9:
FileManager.toDownload(binary, outputDir).then((value: boolean) => {
if (value) {
Downloader.downloadBinary(binary, outputDir);
} else {
logger.info(
binary.name + ': file exists ' +
path.resolve(outputDir, binary.filename(os.type(), os.arch())));
logger.info(binary.name + ': v' + binary.versionCustom + ' up to date');
}
});
示例10: unzip
return FileManager.toDownload(binary, outputDir).then((value: boolean) => {
if (value) {
let deferred = q.defer();
Downloader.downloadBinary(
binary, outputDir, proxy, ignoreSSL,
(binary: Binary, outputDir: string, fileName: string) => {
unzip(binary, outputDir, fileName);
deferred.resolve();
});
return deferred.promise;
} else {
logger.info(
binary.name + ': file exists ' +
path.resolve(outputDir, binary.filename(os.type(), os.arch())));
let fileName = binary.filename(os.type(), os.arch());
unzip(binary, outputDir, fileName);
logger.info(binary.name + ': v' + binary.versionCustom + ' up to date');
}
});