当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript temp.track函数代码示例

本文整理汇总了TypeScript中temp.track函数的典型用法代码示例。如果您正苦于以下问题:TypeScript track函数的具体用法?TypeScript track怎么用?TypeScript track使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了track函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: runCode

export function runCode(argv: any) {
  // run code in temp path, and cleanup
  var temp = require('temp')
  temp.track()
  process.on('SIGINT',  () => temp.cleanupSync())
  process.on('SIGTERM', () => temp.cleanupSync())

  let tempPath = temp.mkdirSync('tsrun')
  let outDir = tempPath
  if (argv.o) {
    outDir = path.join(tempPath, argv.o)
  }
  let compileError = compile(argv._, {
      outDir,
      noEmitOnError: true,
      target: ts.ScriptTarget.ES5,
      module: ts.ModuleKind.CommonJS,
      experimentalDecorators: true,
  })
  if (compileError) process.exit(compileError)
  linkDir(process.cwd(), tempPath)
  // slice argv. 0: node, 1: tsun binary 2: arg
  var newArgv = process.argv.slice(2).map(arg => {
    if (!/\.ts$/.test(arg)) return arg
    return path.join(outDir, arg.replace(/ts$/, 'js'))
  })
  child_process.execFileSync('node', newArgv, {
    stdio: 'inherit'
  })
  process.exit()
}
开发者ID:joelbinn,项目名称:typescript-repl,代码行数:31,代码来源:executor.ts

示例2: addPlatform

	private async addPlatform(platformParam: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, frameworkPath?: string, nativePrepare?: INativePrepare): Promise<void> {
		const data = platformParam.split("@");
		const platform = data[0].toLowerCase();
		let version = data[1];

		const platformData = this.$platformsData.getPlatformData(platform, projectData);

		// Log the values for project
		this.$logger.trace("Creating NativeScript project for the %s platform", platform);
		this.$logger.trace("Path: %s", platformData.projectRoot);
		this.$logger.trace("Package: %s", projectData.projectIdentifiers[platform]);
		this.$logger.trace("Name: %s", projectData.projectName);

		this.$logger.info("Copying template files...");

		let packageToInstall = "";
		if (frameworkPath) {
			packageToInstall = path.resolve(frameworkPath);
			if (!this.$fs.exists(packageToInstall)) {
				const errorMessage = format(constants.AddPlaformErrors.InvalidFrameworkPathStringFormat, frameworkPath);
				this.$errors.fail(errorMessage);
			}
		} else {
			if (!version) {
				version = this.getCurrentPlatformVersion(platform, projectData) ||
					await this.$packageInstallationManager.getLatestCompatibleVersion(platformData.frameworkPackageName);
			}

			packageToInstall = `${platformData.frameworkPackageName}@${version}`;
		}

		const spinner = this.$terminalSpinnerService.createSpinner();
		const platformPath = path.join(projectData.platformsDir, platform);
		let installedPlatformVersion;

		try {
			spinner.start();
			const downloadedPackagePath = temp.mkdirSync("runtimeDir");
			temp.track();
			await this.$pacoteService.extractPackage(packageToInstall, downloadedPackagePath);
			let frameworkDir = path.join(downloadedPackagePath, constants.PROJECT_FRAMEWORK_FOLDER_NAME);
			frameworkDir = path.resolve(frameworkDir);
			installedPlatformVersion =
				await this.addPlatformCore(platformData, frameworkDir, platformTemplate, projectData, config, nativePrepare);
		} catch (err) {
			this.$fs.deleteDirectory(platformPath);
			throw err;
		} finally {
			spinner.stop();
		}

		this.$fs.ensureDirectoryExists(platformPath);
		this.$logger.info(`Platform ${platform} successfully added. v${installedPlatformVersion}`);
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:54,代码来源:platform-service.ts

示例3: ensureTempDir

function ensureTempDir(): string {
  if (_tempDir === undefined) {
    _tempDir = temp.mkdirSync({ prefix: "salve-convert" });

    if (args.keep_temp) {
      temp.track(false);
      console.log(`Temporary files in: ${_tempDir}`);
    }
  }

  return _tempDir;
}
开发者ID:lddubeau,项目名称:salve,代码行数:12,代码来源:convert.ts

示例4: return

		return (() => {
			if(this.$fs.exists(packageFilePath).wait() && path.extname(packageFilePath) === ".zip") {
				temp.track();
				let dir = temp.mkdirSync("simulatorPackage");
				this.$fs.unzip(packageFilePath, dir).wait();
				let app = _.find(this.$fs.readDirectory(dir).wait(), directory => path.extname(directory) === ".app");
				if (app) {
					packageFilePath = path.join(dir, app);
				}
			}

			this.iosSim.installApplication(this.identifier, packageFilePath).wait();
		}).future<void>()();
开发者ID:enchev,项目名称:mobile-cli-lib,代码行数:13,代码来源:ios-simulator-application-manager.ts

示例5: installApplication

	@hook('install')
	public async installApplication(packageFilePath: string): Promise<void> {
		if (this.$fs.exists(packageFilePath) && path.extname(packageFilePath) === ".zip") {
			temp.track();
			const dir = temp.mkdirSync("simulatorPackage");
			await this.$fs.unzip(packageFilePath, dir);
			const app = _.find(this.$fs.readDirectory(dir), directory => path.extname(directory) === ".app");
			if (app) {
				packageFilePath = path.join(dir, app);
			}
		}

		return this.iosSim.installApplication(this.device.deviceInfo.identifier, packageFilePath);
	}
开发者ID:telerik,项目名称:mobile-cli-lib,代码行数:14,代码来源:ios-simulator-application-manager.ts

示例6: unpackAppResourcesCore

	private async unpackAppResourcesCore(appResourcesDir: string, assetsZipFileName: string): Promise<void> {
		temp.track();
		let extractionDir = temp.mkdirSync("appResourcesTemp");

		// In NativeScript templates App_Resources are under app/App_Resources.
		// In Cordova templates App_Resources are at the root.
		// So extract all *App_Resources and filter them after that, so we'll copy the real App_Resources directory to the destination appResourcesDir.
		await this.$fs.unzip(assetsZipFileName, extractionDir, { caseSensitive: false, overwriteExisitingFiles: true }, ["*App_Resources/**"]);

		let appResourcesDirInTemp = _(this.$fs.enumerateFilesInDirectorySync(extractionDir, null, { enumerateDirectories: true }))
			.filter((file: string) => path.basename(file) === "App_Resources")
			.first();

		if (appResourcesDirInTemp) {
			shelljs.cp("-rf", `${appResourcesDirInTemp}`, appResourcesDir);
		}
	}
开发者ID:Icenium,项目名称:icenium-cli,代码行数:17,代码来源:templates-service.ts

示例7: readFile

	// TODO: Remove this method from here. It has nothing to do with platform
	public async readFile(device: Mobile.IDevice, deviceFilePath: string, projectData: IProjectData): Promise<string> {
		temp.track();
		const uniqueFilePath = temp.path({ suffix: ".tmp" });
		const platform = device.deviceInfo.platform.toLowerCase();
		try {
			await device.fileSystem.getFile(deviceFilePath, projectData.projectIdentifiers[platform], uniqueFilePath);
		} catch (e) {
			return null;
		}

		if (this.$fs.exists(uniqueFilePath)) {
			const text = this.$fs.readText(uniqueFilePath);
			shell.rm(uniqueFilePath);
			return text;
		}

		return null;
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:19,代码来源:platform-service.ts

示例8: require

    grunt.registerTask("default", "Compile Internal TypeScript Modules", () => {

        var path = require("path");
        var fs = require("fs");
        var temp = require("temp");
        var FileManager = require("./Scripts/Generic/AgileObjects.Node.FileManager");
        var NodeModuleLoader = require("./Scripts/Generic/AgileObjects.Node.InternalModuleLoader");

        var rootFileName = path.resolve("./app.js");
        var fileManager = new FileManager(path, fs, temp.track(), rootFileName);
        var moduleLoader = new NodeModuleLoader(fileManager, require);

        moduleLoader.createSourceFile(
            "./InternalModules.js",
            ["AgileObjects.TypeScript", "AgileObjects.BoardGameEngine"]);

        grunt.log.writeln("Internal TypeScript modules compiled.");
    });
开发者ID:SteveWilkes,项目名称:BoardGameEngine,代码行数:18,代码来源:gruntfile.ts

示例9: getBundleIdentifier

	private async getBundleIdentifier(data: IITMSData): Promise<string> {
		const { shouldExtractIpa, ipaFilePath } = data;

		if (shouldExtractIpa) {
			if (!this.$fs.exists(ipaFilePath) || path.extname(ipaFilePath) !== ".ipa") {
				this.$errors.failWithoutHelp(`Cannot use specified ipa file ${ipaFilePath}. File either does not exist or is not an ipa file.`);
			}

			this.$logger.trace("--ipa set - extracting .ipa file to get app's bundle identifier");
			temp.track();
			const destinationDir = temp.mkdirSync("ipa-");
			await this.$fs.unzip(ipaFilePath, destinationDir);

			const payloadDir = path.join(destinationDir, "Payload");
			let allFiles = this.$fs.readDirectory(payloadDir);

			this.$logger.debug("ITMSTransporter .ipa Payload files:");
			allFiles.forEach(f => this.$logger.debug(" - " + f));

			allFiles = allFiles.filter(f => path.extname(f).toLowerCase() === ".app");
			if (allFiles.length > 1) {
				this.$errors.failWithoutHelp("In the .ipa the ITMSTransporter is uploading there is more than one .app file. We don't know which one to upload.");
			} else if (allFiles.length <= 0) {
				this.$errors.failWithoutHelp("In the .ipa the ITMSTransporter is uploading there must be at least one .app file.");
			}
			const appFile = path.join(payloadDir, allFiles[0]);

			const plistObject = await this.$plistParser.parseFile(path.join(appFile, INFO_PLIST_FILE_NAME));
			const bundleId = plistObject && plistObject.CFBundleIdentifier;
			if (!bundleId) {
				this.$errors.failWithoutHelp(`Unable to determine bundle identifier from ${ipaFilePath}.`);
			}

			this.$logger.trace(`bundle identifier determined to be ${bundleId}`);

			return bundleId;
		}

		return this.$projectData.projectIdentifiers.ios;
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:40,代码来源:itmstransporter-service.ts

示例10: fullSync

	@performanceLog()
	public async fullSync(syncInfo: IFullSyncInfo): Promise<ILiveSyncResultInfo> {
		const device = syncInfo.device;

		if (device.isEmulator) {
			return super.fullSync(syncInfo);
		}
		const projectData = syncInfo.projectData;
		const platformData = this.$platformsData.getPlatformData(device.deviceInfo.platform, projectData);
		const deviceAppData = await this.getAppData(syncInfo);
		const projectFilesPath = path.join(platformData.appDestinationDirectoryPath, APP_FOLDER_NAME);

		temp.track();
		const tempZip = temp.path({ prefix: "sync", suffix: ".zip" });
		const tempApp = temp.mkdirSync("app");
		this.$logger.trace("Creating zip file: " + tempZip);
		this.$fs.copyFile(path.join(path.dirname(projectFilesPath), `${APP_FOLDER_NAME}/*`), tempApp);

		if (!syncInfo.syncAllFiles) {
			this.$fs.deleteDirectory(path.join(tempApp, TNS_MODULES_FOLDER_NAME));
		}

		await this.$fs.zipFiles(tempZip, this.$fs.enumerateFilesInDirectorySync(tempApp), (res) => {
			return path.join(APP_FOLDER_NAME, path.relative(tempApp, res));
		});

		await device.fileSystem.transferFiles(deviceAppData, [{
			getLocalPath: () => tempZip,
			getDevicePath: () => deviceAppData.deviceSyncZipPath,
			getRelativeToProjectBasePath: () => "../sync.zip",
			deviceProjectRootPath: await deviceAppData.getDeviceProjectRootPath()
		}]);

		return {
			deviceAppData,
			isFullSync: true,
			modifiedFilesData: [],
			useHotModuleReload: syncInfo.useHotModuleReload
		};
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:40,代码来源:ios-livesync-service.ts


注:本文中的temp.track函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。