How to use the tiny-glob/sync.js function in tiny-glob

To help you get started, we’ve selected a few tiny-glob examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sveltejs / svelte / test / helpers.js View on Github external
export function showOutput(cwd, options = {}, compile = svelte.compile) {
	glob('**/*.svelte', { cwd }).forEach(file => {
		if (file[0] === '_') return;

		try {
			const { js } = compile(
				fs.readFileSync(`${cwd}/${file}`, 'utf-8'),
				Object.assign(options, {
					filename: file
				})
			);

			console.log( // eslint-disable-line no-console
				`\n>> ${colors.cyan().bold(file)}\n${addLineNumbers(js.code)}\n<< ${colors.cyan().bold(file)}`
			);
		} catch (err) {
			console.log(`failed to generate output: ${err.message}`);
		}
github sveltejs / svelte / test / parser / update.js View on Github external
// this file will replace all the expected.js and expected-bundle.js files with
// their _actual equivalents. Only use it when you're sure that you haven't
// broken anything!
const fs = require("fs");
const glob = require("tiny-glob/sync.js");

glob("samples/*/_actual.json", { cwd: __dirname }).forEach(file => {
	const actual = fs.readFileSync(`${__dirname}/${file}`, "utf-8");
	fs.writeFileSync(
		`${__dirname}/${file.replace("_actual", "output")}`,
		actual
	);
});
github sveltejs / svelte / test / js / update.js View on Github external
// this file will replace all the expected.js and expected-bundle.js files with
// their _actual equivalents. Only use it when you're sure that you haven't
// broken anything!
const fs = require("fs");
const glob = require("tiny-glob/sync.js");

glob("samples/*/_actual*", { cwd: __dirname }).forEach(file => {
	const actual = fs.readFileSync(`${__dirname}/${file}`, "utf-8");
	fs.writeFileSync(
		`${__dirname}/${file.replace("_actual", "expected")}`,
		actual
	);
});
github sveltejs / svelte / test / cli / index.js View on Github external
);

			if (commandErr) {
				done(commandErr);
				return;
			}

			const actual = glob('**', { cwd: 'actual', filesOnly: true })
				.map(file => {
					return {
						file,
						contents: normalize(fs.readFileSync(`actual/${file}`, 'utf-8'))
					};
				});

			const expected = glob('**', { cwd: 'expected', filesOnly: true })
				.map(file => {
					return {
						file,
						contents: normalize(
							fs.readFileSync(`expected/${file}`, 'utf-8')
						)
					};
				});

			actual.forEach((a, i) => {
				const e = expected[i];

				assert.equal(a.file, e.file, 'File list mismatch');

				if (/\.map$/.test(a.file)) {
					assert.deepEqual(JSON.parse(a.contents), JSON.parse(e.contents));
github sveltejs / svelte / test / server-side-rendering / index.js View on Github external
Object.keys(require.cache)
				.filter(x => x.endsWith('.svelte'))
				.forEach(file => {
					delete require.cache[file];
				});

			delete global.window;

			const compileOptions = Object.assign({ sveltePath }, config.compileOptions, {
				generate: 'ssr',
				format: 'cjs'
			});

			require("../../register")(compileOptions);

			glob('**/*.svelte', { cwd }).forEach(file => {
				if (file[0] === '_') return;

				const dir  = `${cwd}/_output/ssr`;
				const out = `${dir}/${file.replace(/\.svelte$/, '.js')}`;

				if (fs.existsSync(out)) {
					fs.unlinkSync(out);
				}

				mkdirp(dir);

				try {
					const { js } = compile(
						fs.readFileSync(`${cwd}/${file}`, 'utf-8'),
						{
							...compileOptions,
github sveltejs / svelte / test / runtime / index.js View on Github external
compileOptions.accessors = 'accessors' in config ? config.accessors : true;

			Object.keys(require.cache)
				.filter(x => x.endsWith('.svelte'))
				.forEach(file => {
					delete require.cache[file];
				});

			let mod;
			let SvelteComponent;

			let unintendedError = null;

			const window = env();

			glob('**/*.svelte', { cwd }).forEach(file => {
				if (file[0] === '_') return;

				const dir  = `${cwd}/_output/${hydrate ? 'hydratable' : 'normal'}`;
				const out = `${dir}/${file.replace(/\.svelte$/, '.js')}`;

				if (fs.existsSync(out)) {
					fs.unlinkSync(out);
				}

				mkdirp(dir);

				try {
					const { js } = compile(
						fs.readFileSync(`${cwd}/${file}`, 'utf-8'),
						{
							...compileOptions,

tiny-glob

Tiny and extremely fast globbing

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular tiny-glob functions