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


TypeScript shelljs.rm函數代碼示例

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


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

示例1: it

  it("Extract File with folders", () => {
    let extractor = unrar.createExtractorFromFile("./testFiles/FolderTest.rar", "./tmp/", "1234");
    let [state, list] = extractor.extractAll();
    assert.deepStrictEqual(state, { state: "SUCCESS" });

    assert.deepStrictEqual(list!.files[0]!.fileHeader.name, "Folder1/Folder Space/long.txt");
    assert.deepStrictEqual(list!.files[1]!.fileHeader.name, "Folder1/Folder 中文/2中文.txt");
    assert.deepStrictEqual(list!.files[2]!.fileHeader.name, "Folder1/Folder Space");
    assert.deepStrictEqual(list!.files[3]!.fileHeader.name, "Folder1/Folder 中文");
    assert.deepStrictEqual(list!.files[4]!.fileHeader.name, "Folder1");

    let long = "", i = 0;
    while (long.length < 1024 * 1024) {
      long += "1" + "0".repeat(i++);
    }
    assert.equal(fs.readFileSync("./tmp/Folder1/Folder Space/long.txt", "utf-8"), long);

    shjs.rm("-rf", "./tmp");

  });
開發者ID:YuJianrong,項目名稱:nodejs-unrar,代碼行數:20,代碼來源:fileExtractor.spec.ts

示例2: done

                fs.stat(candidate, (err, stats) => {
                    if (err) {
                        done(null);
                        return;
                    }

                    if (stats.isDirectory()) {
                        done(null);
                        return;
                    }

                    var fileAgeSeconds = (new Date().getTime() - stats.mtime.getTime()) / 1000;
                    if (fileAgeSeconds > _that.ageSeconds) {
                        ++delCount;
                        _that.emitter.emit('deleted', candidate);
                        shell.rm(candidate);
                    }                    

                    // ignoring errors - log and keep going
                    done(null);
                })
開發者ID:itsananderson,項目名稱:vso-agent,代碼行數:21,代碼來源:diagnostics.ts

示例3: copyTnsModules

	private async copyTnsModules(platform: string, platformData: IPlatformData, projectData: IProjectData, appFilesUpdaterOptions: IAppFilesUpdaterOptions, projectFilesConfig?: IProjectFilesConfig): Promise<void> {
		const appDestinationDirectoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
		const lastModifiedTime = this.$fs.exists(appDestinationDirectoryPath) ? this.$fs.getFsStats(appDestinationDirectoryPath).mtime : null;

		try {
			const absoluteOutputPath = path.join(appDestinationDirectoryPath, constants.TNS_MODULES_FOLDER_NAME);
			// Process node_modules folder
			await this.$nodeModulesBuilder.prepareJSNodeModules({
				absoluteOutputPath,
				platform,
				lastModifiedTime,
				projectData,
				appFilesUpdaterOptions,
				projectFilesConfig
			});
		} catch (error) {
			this.$logger.debug(error);
			shell.rm("-rf", appDestinationDirectoryPath);
			this.$errors.failWithoutHelp(`Processing node_modules failed. ${error}`);
		}
	}
開發者ID:NathanaelA,項目名稱:nativescript-cli,代碼行數:21,代碼來源:prepare-platform-js-service.ts

示例4: return

		return (() => {
			platform = platform.toLowerCase();
			this.ensurePlatformInstalled(platform).wait();

			let platformData = this.$platformsData.getPlatformData(platform);
			platformData.platformProjectService.ensureConfigurationFileInAppResources().wait();
			let appDestinationDirectoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
			let lastModifiedTime = this.$fs.exists(appDestinationDirectoryPath).wait() ?
				this.$fs.getFsStats(appDestinationDirectoryPath).wait().mtime : null;

			// Copy app folder to native project
			this.$fs.ensureDirectoryExists(appDestinationDirectoryPath).wait();
			let appSourceDirectoryPath = path.join(this.$projectData.projectDir, constants.APP_FOLDER_NAME);

			// Delete the destination app in order to prevent EEXIST errors when symlinks are used.
			let contents = this.$fs.readDirectory(appDestinationDirectoryPath).wait();

			_(contents)
				.filter(directoryName => directoryName !== constants.TNS_MODULES_FOLDER_NAME)
				.each(directoryName => this.$fs.deleteDirectory(path.join(appDestinationDirectoryPath, directoryName)).wait())
				.value();

			// Copy all files from app dir, but make sure to exclude tns_modules
			let sourceFiles = this.$fs.enumerateFilesInDirectorySync(appSourceDirectoryPath, null, { includeEmptyDirectories: true });

			if (this.$options.release) {
				let testsFolderPath = path.join(appSourceDirectoryPath, 'tests');
				sourceFiles = sourceFiles.filter(source => source.indexOf(testsFolderPath) === -1);
			}

			let hasTnsModulesInAppFolder = this.$fs.exists(path.join(appSourceDirectoryPath, constants.TNS_MODULES_FOLDER_NAME)).wait();
			if (hasTnsModulesInAppFolder && this.$projectData.dependencies && this.$projectData.dependencies[constants.TNS_CORE_MODULES_NAME]) {
				this.$logger.warn("You have tns_modules dir in your app folder and tns-core-modules in your package.json file. Tns_modules dir in your app folder will not be used and you can safely remove it.");
				sourceFiles = sourceFiles.filter(source => !minimatch(source, `**/${constants.TNS_MODULES_FOLDER_NAME}/**`, { nocase: true }));
			}

			// verify .xml files are well-formed
			this.$xmlValidator.validateXmlFiles(sourceFiles).wait();

			// Remove .ts and .js.map files
			constants.LIVESYNC_EXCLUDED_FILE_PATTERNS.forEach(pattern => sourceFiles = sourceFiles.filter(file => !minimatch(file, pattern, { nocase: true })));
			let copyFileFutures = sourceFiles.map(source => {
				let destinationPath = path.join(appDestinationDirectoryPath, path.relative(appSourceDirectoryPath, source));
				if (this.$fs.getFsStats(source).wait().isDirectory()) {
					return this.$fs.createDirectory(destinationPath);
				}
				return this.$fs.copyFile(source, destinationPath);
			});
			Future.wait(copyFileFutures);

			// Copy App_Resources to project root folder
			this.$fs.ensureDirectoryExists(platformData.platformProjectService.getAppResourcesDestinationDirectoryPath().wait()).wait(); // Should be deleted
			let appResourcesDirectoryPath = path.join(appDestinationDirectoryPath, constants.APP_RESOURCES_FOLDER_NAME);
			if (this.$fs.exists(appResourcesDirectoryPath).wait()) {
				platformData.platformProjectService.prepareAppResources(appResourcesDirectoryPath).wait();
				shell.cp("-Rf", path.join(appResourcesDirectoryPath, platformData.normalizedPlatformName, "*"), platformData.platformProjectService.getAppResourcesDestinationDirectoryPath().wait());
				this.$fs.deleteDirectory(appResourcesDirectoryPath).wait();
			}

			platformData.platformProjectService.prepareProject().wait();

			let appDir = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
			try {
				let tnsModulesDestinationPath = path.join(appDir, constants.TNS_MODULES_FOLDER_NAME);
				if (!this.$options.bundle) {
					// Process node_modules folder
					this.$broccoliBuilder.prepareNodeModules(tnsModulesDestinationPath, platform, lastModifiedTime).wait();
				} else {
					// Clean target node_modules folder. Not needed when bundling.
					this.$broccoliBuilder.cleanNodeModules(tnsModulesDestinationPath, platform);
				}
			} catch (error) {
				this.$logger.debug(error);
				shell.rm("-rf", appDir);
				this.$errors.failWithoutHelp(`Processing node_modules failed. ${error}`);
			}

			// Process platform specific files
			let directoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
			let excludedDirs = [constants.APP_RESOURCES_FOLDER_NAME];
			this.$projectFilesManager.processPlatformSpecificFiles(directoryPath, platform, excludedDirs).wait();

			this.applyBaseConfigOption(platformData).wait();

			// Process configurations files from App_Resources
			platformData.platformProjectService.processConfigurationFilesFromAppResources().wait();

			// Replace placeholders in configuration files
			platformData.platformProjectService.interpolateConfigurationFile().wait();

			this.$logger.out("Project successfully prepared");
			return true;
		}).future<boolean>()();
開發者ID:Emat12,項目名稱:nativescript-cli,代碼行數:93,代碼來源:platform-service.ts

示例5: deleteFile

	public async deleteFile(deviceFilePath: string, appIdentifier: string): Promise<void> {
		shelljs.rm("-rf", deviceFilePath);
	}
開發者ID:NativeScript,項目名稱:nativescript-cli,代碼行數:3,代碼來源:ios-simulator-file-system.ts

示例6: rm

 ['index.html', 'foo.js', 'foo/index.html', 'foo'].forEach(relFilePath => {
   const absFilePath = path.join(AIO_BUILDS_DIR, relFilePath);
   rm('-r', absFilePath);
 });
開發者ID:DeepanParikh,項目名稱:angular,代碼行數:4,代碼來源:nginx.e2e.ts

示例7: usage

  console.error(
    `Folder ${folder} not found at ${path.join(process.cwd(), folder)}`
  );
  usage(true);
}

// Define template html, user's first, otherwise default
let template = path.join(folder, templateFilename);
if (!sh.test("-e", template)) {
  template = path.join(__dirname, defaultFolder, templateFilename);
}
const tpl = sh.cat(template);

// Prepare output folder (create, clean, copy sources)
sh.mkdir("-p", output);
sh.rm("-rf", output + "/*");
sh.cp("-R", folder + "/*", output);

// Start processing. Outline:
//
// 1. Get all files
// 2. Sort them
// 3. Group them hierachically
// 4. Parse files and generate output html files

sh.cd(output);
const all = sh.find("*");

const mds = all
  .filter(file => file.match(mdR))
  .sort(sortByPreferences.bind(null, preferences))
開發者ID:joakin,項目名稱:markdown-folder-to-html,代碼行數:31,代碼來源:cli.ts

示例8: afterEach

 afterEach(function() {
     sh.rm("-r", configDir);
 });
開發者ID:textlint,項目名稱:textlint,代碼行數:3,代碼來源:config-initializer-test.ts

示例9: stop

export function stop() {
	if (shell.test('-f', _pidPath)) {
		shell.rm(_pidPath);
	}
}
開發者ID:ElleCox,項目名稱:vso-agent,代碼行數:5,代碼來源:heartbeat.ts

示例10: afterEach

 afterEach(() => shx.rm('-r', tmpDir));
開發者ID:Cammisuli,項目名稱:angular,代碼行數:1,代碼來源:no_template_variable_assignment_rule_spec.ts


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