本文整理匯總了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 || ''));
});
示例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);
};
示例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);
}
示例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)
})
示例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);
}
}
示例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);
}
示例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]);
}
}
示例8:
files.forEach(str => {
console.log(
fs.statSync(str).isDirectory() ? chalk.cyan(str) :
str[0] === '.' ? chalk.grey(str) :
chalk.red(str)
)
})
示例9: catch
.filter(file => {
try {
return fs.statSync(file).isFile();
} catch (statError) {
return false;
}
})
示例10: isDir
export function isDir (mpath: MPath): boolean {
let spath = pathToString(mpath)
if (!fs.existsSync(spath)) return false
return fs.statSync(spath).isDirectory()
}