当前位置: 首页>>代码示例>>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;未经允许,请勿转载。