本文整理汇总了TypeScript中temp.mkdirSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mkdirSync函数的具体用法?TypeScript mkdirSync怎么用?TypeScript mkdirSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkdirSync函数的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: return
return (() => {
if (!selectedTemplate) {
// read data from package.json's nativescript key
// check the nativescript.tns-<platform>.template value
let nativescriptPlatformData = this.$projectDataService.getValue(frameworkPackageName).wait();
selectedTemplate = nativescriptPlatformData && nativescriptPlatformData.template;
}
if (selectedTemplate) {
let tempDir = temp.mkdirSync("platform-template");
try {
/*
* Output of npm.install is array of arrays. For example:
* [ [ '[email protected]',
* 'C:\\Users\\<USER>~1\\AppData\\Local\\Temp\\1\\platform-template11627-15560-rm3ngx\\node_modules\\test-android-platform-template',
* undefined,
* undefined,
* '..\\..\\..\\android-platform-template' ] ]
* Project successfully created.
*/
let pathToTemplate = this.$npm.install(selectedTemplate, tempDir).wait()[0][1];
return { selectedTemplate, pathToTemplate };
} catch (err) {
this.$logger.trace("Error while trying to install specified template: ", err);
this.$errors.failWithoutHelp(`Unable to install platform template ${selectedTemplate}. Make sure the specified value is valid.`);
}
}
return null;
}).future<any>()();
开发者ID:Emat12,项目名称:nativescript-cli,代码行数:30,代码来源:platform-service.ts
示例3: updatePlatform
private async updatePlatform(platform: string, version: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
const platformData = this.$platformsData.getPlatformData(platform, projectData);
const data = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);
const currentVersion = data && data.version ? data.version : "0.2.0";
const installedModuleDir = temp.mkdirSync("runtime-to-update");
let newVersion = version === constants.PackageVersion.NEXT ?
await this.$packageInstallationManager.getNextVersion(platformData.frameworkPackageName) :
version || await this.$packageInstallationManager.getLatestCompatibleVersion(platformData.frameworkPackageName);
await this.$pacoteService.extractPackage(`${platformData.frameworkPackageName}@${newVersion}`, installedModuleDir);
const cachedPackageData = this.$fs.readJson(path.join(installedModuleDir, "package.json"));
newVersion = (cachedPackageData && cachedPackageData.version) || newVersion;
const canUpdate = platformData.platformProjectService.canUpdatePlatform(installedModuleDir, projectData);
if (canUpdate) {
if (!semver.valid(newVersion)) {
this.$errors.fail("The version %s is not valid. The version should consists from 3 parts separated by dot.", newVersion);
}
if (!semver.gt(currentVersion, newVersion)) {
await this.updatePlatformCore(platformData, { currentVersion, newVersion, canUpdate, platformTemplate }, projectData, config);
} else if (semver.eq(currentVersion, newVersion)) {
this.$errors.fail("Current and new version are the same.");
} else {
this.$errors.fail(`Your current version: ${currentVersion} is higher than the one you're trying to install ${newVersion}.`);
}
} else {
this.$errors.failWithoutHelp("Native Platform cannot be updated.");
}
}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:31,代码来源:platform-service.ts
示例4: it
it('should handle lifetime invoke test 1', function (done) {
// for now, just check that the thing actually runs
var outputDir = temp.mkdirSync();
var test = "test/testdata/testRefCount13.js";
var instProc = cp.spawn("./bin/meminsight", [
"instrument",
"--outputDir",
outputDir,
test
]);
instProc.on('close', () => {
var runProc = cp.spawn("./bin/meminsight", [
"noderun",
path.join(outputDir, "testRefCount13_inst", "testRefCount13_jalangi_.js")
]);
runProc.on('close', () => {
var stalenessTrace = String(fs.readFileSync(path.join(outputDir,"testRefCount13_inst", 'staleness-trace')));
stalenessTrace = stalenessTrace.replace(new RegExp(process.cwd() + path.sep,'g'), "");
var expectedLine = '[9,"OBJECT","test/testdata/testRefCount13.js:20:19:20:38",15,["test/testdata/testRefCount13.js:25:8:25:11"],15,"test/testdata/testRefCount13.js:20:19:20:38",37,"end of program"]';
assert.ok(stalenessTrace.indexOf(expectedLine) !== -1);
temp.cleanupSync();
done();
})
});
});
开发者ID:KrupaR,项目名称:meminsight,代码行数:25,代码来源:lifetimeAnalysisInvokeTests.ts
示例5: updateMigrationConfigFile
public async updateMigrationConfigFile(): Promise<void> {
try {
let nativeScriptMigrationFileName = this.$nativeScriptResources.nativeScriptMigrationFile;
let currentMigrationConfigStatus = this.$fs.getFsStats(nativeScriptMigrationFileName);
let currentTime = this.$dateProvider.getCurrentDate();
if (currentTime.getTime() - currentMigrationConfigStatus.mtime.getTime() < FrameworkProjectBase.MAX_MIGRATION_FILE_EDIT_TIME_DIFFERENCE) {
// We do not need to update the migration file if it has been modified in the past 2 hours.
this.$logger.trace(`The current NativeScript migration file was updated on ${currentMigrationConfigStatus.mtime}.`);
return;
}
let downloadDestinationDirectory = temp.mkdirSync("nativescript-migration");
let downloadedFilePath = path.join(downloadDestinationDirectory, "nativeScript-migration-data.json");
await this.$nativeScriptMigrationService.downloadMigrationConfigFile(downloadedFilePath);
let newMigrationFileContent = this.$fs.readText(downloadedFilePath);
let currentMigrationFileContent = this.$fs.readText(nativeScriptMigrationFileName);
if (currentMigrationFileContent !== newMigrationFileContent) {
this.$fs.writeFile(nativeScriptMigrationFileName, newMigrationFileContent);
this.$logger.trace(`NativeScript migration file updated on ${currentTime}.`);
} else {
this.$fs.utimes(nativeScriptMigrationFileName, currentTime, currentTime);
}
} catch (err) {
this.$logger.trace("Failed to download the NativeScript migration file.", err);
}
}
开发者ID:Icenium,项目名称:icenium-cli,代码行数:30,代码来源:nativescript-project.ts
示例6: function
export default function(argv: any) {
// Get to a temporary directory.
let tempRoot = argv.reuse || temp.mkdirSync('angular-cli-e2e-');
console.log(` Using "${tempRoot}" as temporary directory for a new project.`);
setGlobalVariable('tmp-root', tempRoot);
process.chdir(tempRoot);
}
开发者ID:JasonGoemaat,项目名称:angular-cli,代码行数:7,代码来源:200-create-tmp-dir.ts
示例7: getPathToPlatformTemplate
private async getPathToPlatformTemplate(selectedTemplate: string, frameworkPackageName: string, projectDir: string): Promise<{ selectedTemplate: string, pathToTemplate: string }> {
if (!selectedTemplate) {
// read data from package.json's nativescript key
// check the nativescript.tns-<platform>.template value
const nativescriptPlatformData = this.$projectDataService.getNSValue(projectDir, frameworkPackageName);
selectedTemplate = nativescriptPlatformData && nativescriptPlatformData.template;
}
if (selectedTemplate) {
const tempDir = temp.mkdirSync("platform-template");
this.$fs.writeJson(path.join(tempDir, constants.PACKAGE_JSON_FILE_NAME), {});
try {
const npmInstallResult = await this.$npm.install(selectedTemplate, tempDir, {
disableNpmInstall: false,
frameworkPath: null,
ignoreScripts: false
});
const pathToTemplate = path.join(tempDir, constants.NODE_MODULES_FOLDER_NAME, npmInstallResult.name);
return { selectedTemplate, pathToTemplate };
} catch (err) {
this.$logger.trace("Error while trying to install specified template: ", err);
this.$errors.failWithoutHelp(`Unable to install platform template ${selectedTemplate}. Make sure the specified value is valid.`);
}
}
return null;
}
开发者ID:NathanaelA,项目名称:nativescript-cli,代码行数:27,代码来源:prepare-platform-js-service.ts
示例8: 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
示例9: 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
示例10: function
export default function() {
const argv = getGlobalVariable('argv');
// Get to a temporary directory.
let tempRoot = argv.tmpdir || temp.mkdirSync('angular-cli-e2e-');
if (argv.reuse) {
tempRoot = dirname(argv.reuse);
}
console.log(` Using "${tempRoot}" as temporary directory for a new project.`);
setGlobalVariable('tmp-root', tempRoot);
process.chdir(tempRoot);
}
开发者ID:DevIntent,项目名称:angular-cli,代码行数:12,代码来源:200-create-tmp-dir.ts
注:本文中的temp.mkdirSync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论