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


TypeScript fs-extra.statSync函數代碼示例

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


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

示例1: test

      test(`packages/${fixtureBasename}`, async () => {
        const fixtureSourceDir = path.join(fixtureDir, 'source');
        const fixtureExpectedDir = path.join(fixtureDir, 'expected');
        const fixtureResultDir = path.join(fixtureDir, 'generated');
        const fixtureTestConfig =
            require(path.join(fixtureDir, 'test.js')) as TestConfig;
        assert.isOk(fs.statSync(fixtureSourceDir).isDirectory());
        assert.isOk(fs.statSync(fixtureExpectedDir).isDirectory());

        const output = await runFixture(
            fixtureSourceDir, fixtureResultDir, fixtureTestConfig);

        // 1. Check stderr output that no (unexpected) errors were emitted.
        assert.equal(output.stderr, (fixtureTestConfig.stderr || ''));
        // 2. Compare the generated output to the expected conversion.
        //    Output the diff & fail if any differences are encountered.
        const diffResult =
            dircompare.compareSync(fixtureResultDir, fixtureExpectedDir, {
              compareSize: true,
              compareContent: true,
              excludeFilter: 'bower_components',
            });
        if (!diffResult.same) {
          const diffOutput = createDiffConflictOutput(diffResult);
          throw new Error(diffOutput);
        }

        // 1. Check stdout output that no (unexpected) output was emitted.
        assert.equal(output.stdout, (fixtureTestConfig.stdout || ''));
      });
開發者ID:,項目名稱:,代碼行數:30,代碼來源:

示例2: expect

 const expectations = () => {
   const sizeA = fse.statSync("a.json").size;
   const sizeB = fse.statSync("b.json").size;
   const sizeC = fse.statSync("c.json").size;
   expect(sizeB).to.be.above(sizeA);
   expect(sizeC).to.be.above(sizeB);
 };
開發者ID:szwacz,項目名稱:fs-jetpack,代碼行數:7,代碼來源:file.spec.ts

示例3: hxml

function hxml(projectdir: string, options: any) {
	let data = '';
	for (let i = 0; i < options.sources.length; ++i) {
		if (path.isAbsolute(options.sources[i])) {
			data += '-cp ' + options.sources[i] + '\n';
		}
		else {
			data += '-cp ' + path.relative(projectdir, path.resolve(options.from, options.sources[i])) + '\n'; // from.resolve('build').relativize(from.resolve(this.sources[i])).toString());
		}
	}
	for (let i = 0; i < options.libraries.length; ++i) {
		if (path.isAbsolute(options.libraries[i].libpath)) {
			data += '-cp ' + options.libraries[i].libpath + '\n';
		}
		else {
			data += '-cp ' + path.relative(projectdir, path.resolve(options.from, options.libraries[i].libpath)) + '\n'; // from.resolve('build').relativize(from.resolve(this.sources[i])).toString());
		}
	}
	for (let d in options.defines) {
		let define = options.defines[d];
		data += '-D ' + define + '\n';
	}
	if (options.language === 'cpp') {
		data += '-cpp ' + path.normalize(options.to) + '\n';
	}
	else if (options.language === 'cs') {
		data += '-cs ' + path.normalize(options.to) + '\n';
		if (fs.existsSync(options.haxeDirectory) && fs.statSync(options.haxeDirectory).isDirectory() && fs.existsSync(path.join(options.haxeDirectory, 'netlib'))) {
			data += '-net-std ' + path.relative(projectdir, path.join(options.haxeDirectory, 'netlib')) + '\n';
		}
	}
	else if (options.language === 'java') {
		data += '-java ' + path.normalize(options.to) + '\n';
		if (fs.existsSync(options.haxeDirectory) && fs.statSync(options.haxeDirectory).isDirectory() && fs.existsSync(path.join(options.haxeDirectory, 'hxjava', 'hxjava-std.jar'))) {
			data += '-java-lib ' + path.relative(projectdir, path.join(options.haxeDirectory, 'hxjava', 'hxjava-std.jar')) + '\n';
		}
	}
	else if (options.language === 'js') {
		data += '-js ' + path.normalize(options.to) + '\n';
	}
	else if (options.language === 'as') {
		data += '-swf ' + path.normalize(options.to) + '\n';
		data += '-swf-version ' + options.swfVersion + '\n';
		data += '-swf-header ' + options.width + ':' + options.height + ':' + options.framerate + ':' + options.stageBackground + '\n';
	}
	else if (options.language === 'xml') {
		data += '-xml ' + path.normalize(options.to) + '\n';
		data += '--macro include(\'kha\')\n';
	}
	else if (options.language === 'hl') {
		data += '-hl ' + path.normalize(options.to) + '\n';
	}
	for (let param of options.parameters) {
		data += param + '\n';
	}
	data += '-main Main' + '\n';
	fs.outputFileSync(path.join(projectdir, 'project-' + options.system + '.hxml'), data);
}
開發者ID:jefvel,項目名稱:khamake,代碼行數:58,代碼來源:HaxeProject.ts

示例4: it

 it('downloaded yamls and binaries are as expected', async() => {
   fsExtra.removeSync('./test.temp')
   await s.login('goodUser', 'goodPwd')
   await s.loadProducts()
   s.selection.add(s.products[0])
   s.suspendOnEach = false
   await s.backupSelection()
   const prod1Yaml = await yamlLoader('./test.temp/ResourceBackup/TPT/resources/2632990/resource.info')
   expect(prod1Yaml).to.eql(tptMocks.prod1Yaml)
   expect(fsExtra.statSync('./test.temp/ResourceBackup/TPT/resources/2632990/primary-download').size).to.eql(318923)
   expect(fsExtra.statSync('./test.temp/ResourceBackup/TPT/resources/2632990/coverImage.jpg').size).to.eql(35445)
 })
開發者ID:tes,項目名稱:resource-backup-tool,代碼行數:12,代碼來源:tpt.tests.ts

示例5: searchFiles

	searchFiles(current: any) {
		if (current === undefined) {
			for (let sub of this.subProjects) sub.searchFiles(undefined);
			this.searchFiles(this.basedir);
			// std::set<std::string> starts;
			// for (std::string include : includes) {
			//     if (!isAbsolute(include)) continue;
			//     std::string start = include.substr(0, firstIndexOf(include, '*'));
			//     if (starts.count(start) > 0) continue;
			//     starts.insert(start);
			//     searchFiles(Paths::get(start));
			// }
			return;
		}

		let files = fs.readdirSync(current);
		nextfile: for (let f in files) {
			let file = path.join(current, files[f]);
			if (fs.statSync(file).isDirectory()) continue;
			// if (!current.isAbsolute())
			file = path.relative(this.basedir, file);
			for (let exclude of this.excludes) {
				if (this.matches(this.stringify(file), exclude)) continue nextfile;
			}
			for (let includeobject of this.includes) {
				let include = includeobject.file;
				if (isAbsolute(include)) {
					let inc = include;
					inc = path.relative(this.basedir, inc);
					include = inc;
				}
				if (this.matches(this.stringify(file), include)) {
					this.addFileForReal(this.stringify(file), includeobject.options);
				}
			}
		}

		let dirs = fs.readdirSync(current);
		nextdir: for (let d of dirs) {
			let dir = path.join(current, d);
			if (d.startsWith('.')) continue;
			if (!fs.statSync(dir).isDirectory()) continue;
			for (let exclude of this.excludes) {
				if (this.matchesAllSubdirs(path.relative(this.basedir, dir), exclude)) {
					continue nextdir;
				}
			}
			this.searchFiles(dir);
		}
	}
開發者ID:hammeron-art,項目名稱:koremake,代碼行數:50,代碼來源:Project.ts

示例6: fillConfigDefaults

export function fillConfigDefaults(userConfigFile: string, defaultConfigFile: string): any {
  let userConfig: any = null;

  if (userConfigFile) {
    try {
      // check if exists first, so we can print a more specific error message
      // since required config could also throw MODULE_NOT_FOUND
      statSync(userConfigFile);
      // create a fresh copy of the config each time
      userConfig = require(userConfigFile);
    } catch (e) {
      if (e.code === 'ENOENT') {
        console.error(`Config file "${userConfigFile}" not found. Using defaults instead.`);
      } else {
        console.error(`There was an error in config file "${userConfigFile}". Using defaults instead.`);
        console.error(e);
      }
    }
  }

  const defaultConfig = require(join('..', '..', 'config', defaultConfigFile));

  // create a fresh copy of the config each time
  // always assign any default values which were not already supplied by the user
  return objectAssign({}, defaultConfig, userConfig);
}
開發者ID:Kode-Kitchen,項目名稱:ionic-app-scripts,代碼行數:26,代碼來源:config.ts

示例7: compileShader

function compileShader(projectDir, type, from, to, temp, platform, nokrafix) {
	let compiler = '';
	
	if (Project.koreDir !== '') {
		if (nokrafix) {
			compiler = path.resolve(Project.koreDir, 'Tools', 'kfx', 'kfx' + exec.sys());
		}
		else {
			compiler = path.resolve(Project.koreDir, 'Tools', 'krafix', 'krafix' + exec.sys());
		}
	}

	if (fs.existsSync(path.join(projectDir.toString(), 'Backends'))) {
		let libdirs = fs.readdirSync(path.join(projectDir.toString(), 'Backends'));
		for (let ld in libdirs) {
			let libdir = path.join(projectDir.toString(), 'Backends', libdirs[ld]);
			if (fs.statSync(libdir).isDirectory()) {
				let exe = path.join(libdir, 'krafix', 'krafix-' + platform + '.exe');
				if (fs.existsSync(exe)) {
					compiler = exe;
				}
			}
		}
	}

	if (compiler !== '') {
		child_process.spawnSync(compiler, [type, from, to, temp, platform]);
	}
}
開發者ID:romamik,項目名稱:koremake,代碼行數:29,代碼來源:main.ts

示例8:

files.forEach(str => {
  console.log(
    fs.statSync(str).isDirectory() ? chalk.cyan(str) :
    str[0] === '.' ? chalk.grey(str) :
    chalk.red(str)
  )
})
開發者ID:ZombieHippie,項目名稱:fantastic-repository,代碼行數:7,代碼來源:upload-artifacts.ts

示例9: catch

 .filter(file => {
   try {
     return fs.statSync(file).isFile();
   } catch (statError) {
     return false;
   }
 })
開發者ID:wireapp,項目名稱:wire-desktop,代碼行數:7,代碼來源:main.ts

示例10: isDir

export function isDir (mpath: MPath): boolean {
  let spath = pathToString(mpath)

  if (!fs.existsSync(spath)) return false

  return fs.statSync(spath).isDirectory()
}
開發者ID:bbxyard,項目名稱:bbxyard,代碼行數:7,代碼來源:tool.ts


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