当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs-extra.outputFileSync函数代码示例

本文整理汇总了TypeScript中fs-extra.outputFileSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript outputFileSync函数的具体用法?TypeScript outputFileSync怎么用?TypeScript outputFileSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了outputFileSync函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createNpmBinScript

export function createNpmBinScript(execName: string): void {
    let fileName: string;
    let script: string;

    if (process.platform === 'win32') {
        fileName = `${execName}.cmd`;
        script = `.\\.ruff\\bin\\${execName}.exe %*`;
    } else {
        fileName = execName;
        script = `\
#!/bin/sh
./.ruff/bin/${execName} "$@"`;
    }

    let filePath = Path.resolve('node_modules/.bin', fileName);
    FS.outputFileSync(filePath, script);

    if (process.platform !== 'win32') {
        FS.chmodSync(filePath, 0o744);
    }
}
开发者ID:vilic,项目名称:rvm,代码行数:21,代码来源:index.ts

示例2: readdirSync

export = () => {
  const modules: string[] = readdirSync(Config.APP_SRC);
  let modulesContent = '/* tslint:disable */\n';
  const classes = [];
  for (const module of modules) {
    const moduleFilePath = `${Config.APP_SRC}/${module}/client/${_.kebabCase(module)}.module.ts`;
    if (existsSync(moduleFilePath)) {
      const {importPath, className} = parseFilePath(moduleFilePath, Config.APP_SRC);
      modulesContent += `import { ${className} } from '../${config.APP_SRC}${importPath}';\n`;
      classes.push(className);
    }
  }
  modulesContent = `${modulesContent}
export const PLUGIN_MODULES = [
  ${classes.join(',\n  ')}
];
`;
  const modulesFilesPath = join(config.GEN_FOLDER, 'modules.ts');
  let isSame = false;
  try {
    isSame = readFileSync(modulesFilesPath, 'utf-8') === modulesContent;
  } catch (ignored) {
  }
  if (!isSame) {
    outputFileSync(modulesFilesPath, modulesContent);
  }

  function pascalCase(string: string) {
    return _.upperFirst(_.camelCase(string));
  }

  function parseFilePath(file: string, componentsPath: string) {
    componentsPath = componentsPath.replace(/\\/g, '/');
    const importPath = file.replace(componentsPath, '').replace('.ts', '');
    const split = importPath.split('/');
    const className = pascalCase(split[split.length - 1].replace(/-/g, '.'));
    return {importPath, className};
  }
};
开发者ID:our-city-app,项目名称:gae-plugin-framework,代码行数:39,代码来源:build.plugins.typescript.ts

示例3: test

  test('load yml with secret and env var in .env', async () => {
    const secret = 'this-is-a-long-secret'
    const yml = `\
service: jj
stage: dev
cluster: local

datamodel:
- datamodel.prisma

secret: \${env:MY_DOT_ENV_SECRET}

schema: schemas/database.graphql
    `
    const datamodel = `
type User @model {
  id: ID! @isUnique
  name: String!
  lol: Int
  what: String
}
`
    const { definition, env } = makeDefinition(yml, datamodel, {})
    const envPath = path.join(definition.definitionDir, '.env')

    fs.outputFileSync(
      envPath,
      `MY_DOT_ENV_SECRET=this-is-very-secret,and-comma,seperated`,
    )

    await env.load()

    try {
      await loadDefinition(yml, datamodel)
    } catch (e) {
      expect(e).toMatchSnapshot()
    }
  })
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:38,代码来源:PrismaDefinition.test.ts

示例4: prepareTestUser

    function prepareTestUser() {

        // Set up basic logged in user data, this will be the active user
        const userData = {
            id: "api_testuser",
            token: "tokentoken",
            url: "https://api.sbgenomics.com",
            user: {username: "testuser",}
        };

        // This is the full path of the local profile file
        const localPath = dir.name + "/local";

        // Write basic user data to that profile file, so we don't start with a blank state
        const profileData = {
            credentials: [userData],
            activeCredentials: userData
        } as Partial<UserRepository>;

        fs.outputFileSync(localPath, JSON.stringify(profileData));

        return userData;
    }
开发者ID:hmenager,项目名称:composer,代码行数:23,代码来源:data-repository.spec.ts

示例5: cloneOnConfigFetched

    function cloneOnConfigFetched(cfg: string) {
        var json: string = fs.readFileSync(cfg, 'utf8');

        let config: {
            defaultBranchName: string,
            refs: Object,
            commits: Object,
        } = JSON.parse(json);

        let nconfig = {
            defaultBranchName: config.defaultBranchName,
            currentBranchName: config.defaultBranchName,
            refs: config.refs,
            commits: config.commits,
            staged: []
        };

        var json = JSON.stringify(nconfig);
        fse.outputFileSync(cfg, json);

        let repo = new Common.Repo(process.cwd());
        repo.saveConfig();
        log.info(repo.name + ':', colors.yellow('' + repo.commits.length), 'commits');
    }
开发者ID:STALKER2010,项目名称:jerk,代码行数:24,代码来源:cli.ts

示例6:

 return bootloader.serializeApplication().then(html =>  fse.outputFileSync(path.resolve(this.outputPath, this.indexPath), html, 'utf-8'));
开发者ID:QuinntyneBrown,项目名称:issue-zero,代码行数:1,代码来源:broccoli-app-shell.ts

示例7:

 const preparations = () => {
   fse.outputFileSync("file.txt", test.content);
 };
开发者ID:szwacz,项目名称:fs-jetpack,代码行数:3,代码来源:inspect.spec.ts

示例8:

 const preparations = () => {
   fse.outputFileSync("a/b/c.md", "abc");
 };
开发者ID:szwacz,项目名称:fs-jetpack,代码行数:3,代码来源:find.spec.ts

示例9:

 const preparations = () => {
   fse.mkdirsSync("dir/empty");
   fse.outputFileSync("dir/empty.txt", "");
   fse.outputFileSync("dir/file.txt", "abc");
   fse.outputFileSync("dir/subdir/file.txt", "defg");
 };
开发者ID:szwacz,项目名称:fs-jetpack,代码行数:6,代码来源:inspect_tree.spec.ts

示例10:

 const preparations = () => {
   fse.outputFileSync(filePath, "xyz");
   // Simulating remained file from interrupted previous write attempt.
   fse.outputFileSync(tempPath, "123");
 };
开发者ID:szwacz,项目名称:fs-jetpack,代码行数:5,代码来源:write_atomic.spec.ts

示例11:

 const preparations = () => {
   fse.mkdirsSync("a/b/c");
   fse.outputFileSync("a/f.txt", "abc");
   fse.outputFileSync("a/b/f.txt", "123");
 };
开发者ID:szwacz,项目名称:fs-jetpack,代码行数:5,代码来源:remove.spec.ts

示例12: writeFile

 private writeFile(buffer: Buffer, fileName: string, baseDir = Configuration.baseDir): string {
     const fullFilePath = path.join(baseDir, fileName);
     fs.outputFileSync(fullFilePath, buffer);
     return fullFilePath;
 }
开发者ID:KnowledgeExpert,项目名称:allure-client,代码行数:5,代码来源:attachment.ts

示例13: exportKhaProject


//.........这里部分代码省略.........
	}
	
	let windowOptions = project.windowOptions ? project.windowOptions : defaultWindowOptions;
	exporter.setName(project.name);
	exporter.setWidthAndHeight(
		'width' in windowOptions ? windowOptions.width : defaultWindowOptions.width,
		'height' in windowOptions ? windowOptions.height : defaultWindowOptions.height
	);
	
	for (let source of project.sources) {
		exporter.addSourceDirectory(source);
	}
	for (let library of project.libraries) {
		exporter.addLibrary(library);
	}
	exporter.parameters = project.parameters;
	project.scriptdir = options.kha;
	project.addShaders('Sources/Shaders/**', {});
	project.addShaders('Kha/Sources/Shaders/**', {}); //**

	let assetConverter = new AssetConverter(exporter, options.target, project.assetMatchers);
	let assets = await assetConverter.run(options.watch);
	let shaderDir = path.join(options.to, exporter.sysdir() + '-resources');
	/*if (platform === Platform.Unity) {
		shaderDir = path.join(to, exporter.sysdir(), 'Assets', 'Shaders');
	}
	fs.ensureDirSync(shaderDir);
	for (let shader of project.shaders) {
		await compileShader(exporter, platform, project, shader, shaderDir, temp, krafix);
		if (platform === Platform.Unity) {
			fs.ensureDirSync(path.join(to, exporter.sysdir() + '-resources'));
			fs.writeFileSync(path.join(to, exporter.sysdir() + '-resources', shader.name + '.hlsl'), shader.name);
		}
	}
	if (platform === Platform.Unity) {
		let proto = fs.readFileSync(path.join(from, options.kha, 'Tools', 'khamake', 'Data', 'unity', 'Shaders', 'proto.shader'), { encoding: 'utf8' });
		for (let i1 = 0; i1 < project.exportedShaders.length; ++i1) {
			if (project.exportedShaders[i1].name.endsWith('.vert')) {
				for (let i2 = 0; i2 < project.exportedShaders.length; ++i2) {
					if (project.exportedShaders[i2].name.endsWith('.frag')) {
						let shadername = project.exportedShaders[i1].name + '.' + project.exportedShaders[i2].name;
						let proto2 = proto.replace(/{name}/g, shadername);
						proto2 = proto2.replace(/{vert}/g, project.exportedShaders[i1].name);
						proto2 = proto2.replace(/{frag}/g, project.exportedShaders[i2].name);
						fs.writeFileSync(path.join(shaderDir, shadername + '.shader'), proto2, { encoding: 'utf8' });
					}
				}
			}
		}
		let blobDir = path.join(to, exporter.sysdir(), 'Assets', 'Resources', 'Blobs');
		fs.ensureDirSync(blobDir);
		for (let i = 0; i < project.exportedShaders.length; ++i) {
			fs.writeFileSync(path.join(blobDir, project.exportedShaders[i].files[0] + '.bytes'), project.exportedShaders[i].name, { encoding: 'utf8' });
		}
	}*/
	
	fs.ensureDirSync(shaderDir);
	let shaderCompiler = new ShaderCompiler(exporter, options.target, options.krafix, shaderDir, temp, options, project.shaderMatchers);
	let exportedShaders = await shaderCompiler.run(options.watch);

	let files = [];
	for (let asset of assets) {
		files.push({
			name: fixName(asset.name),
			files: asset.files,
			type: asset.type
		});
	}
	for (let shader of exportedShaders) {
		files.push({
			name: fixName(shader.name),
			files: shader.files,
			type: 'shader'
		});
	}

	function secondPass() {
		// First pass is for main project files. Second pass is for shaders.
		// Will try to look for the folder, e.g. 'build/Shaders'.
		// if it exists, export files similar to other a
		let hxslDir = path.join('build', 'Shaders');
		/** if (fs.existsSync(hxslDir) && fs.readdirSync(hxslDir).length > 0) {
			addShaders(exporter, platform, project, from, to.resolve(exporter.sysdir() + '-resources'), temp, from.resolve(Paths.get(hxslDir)), krafix);
			if (foundProjectFile) {
				fs.outputFileSync(to.resolve(Paths.get(exporter.sysdir() + '-resources', 'files.json')).toString(), JSON.stringify({ files: files }, null, '\t'), { encoding: 'utf8' });
				log.info('Assets done.');
				exportProjectFiles(name, from, to, options, exporter, platform, khaDirectory, haxeDirectory, kore, project.libraries, project.targetOptions, callback);
			}
			else {
				exportProjectFiles(name, from, to, options, exporter, platform, khaDirectory, haxeDirectory, kore, project.libraries, project.targetOptions, callback);
			}
		}*/
	}

	if (foundProjectFile) {
		fs.outputFileSync(path.join(options.to, exporter.sysdir() + '-resources', 'files.json'), JSON.stringify({ files: files }, null, '\t'));
	}

	return await exportProjectFiles(project.name, options, exporter, kore, korehl, project.libraries, project.targetOptions, project.defines);
}
开发者ID:npretto,项目名称:khamake,代码行数:101,代码来源:main.ts

示例14:

fs.mkdirs(dir).then(() => {
	// stub
});
fs.mkdirp(dir).then(() => {
	// stub
});
fs.mkdirs(dir, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirp(dir, errorCallback);
fs.mkdirpSync(dir);

fs.outputFile(file, data).then(() => {
	// stub
});
fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);

fs.outputJson(file, data, {
	spaces: 2
}).then(() => {
	// stub
});
fs.outputJson(file, data, {
	spaces: 2
}, errorCallback);
fs.outputJSON(file, data, errorCallback);
fs.outputJSON(file, data).then(() => {
	// stub
});

fs.outputJsonSync(file, data);
开发者ID:gilamran,项目名称:DefinitelyTyped,代码行数:31,代码来源:fs-extra-tests.ts

示例15: expect

 const preparations = () => {
   fse.outputFileSync("dir1/dir2/file.txt", "abc");
   jetpack.symlink("../dir1", "foo/symlink_to_dir1");
   expect(jetpack.read("foo/symlink_to_dir1/dir2/file.txt")).to.eql("abc");
 };
开发者ID:szwacz,项目名称:fs-jetpack,代码行数:5,代码来源:find.spec.ts


注:本文中的fs-extra.outputFileSync函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。