How to use the vinyl function in vinyl

To help you get started, we’ve selected a few vinyl 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 jgable / gulp-cache / test / index.js View on Github external
const outputFile1 = file.clone({ contents: false }),
					outputFile2 = file.clone({ contents: false });

				outputFile1.contents = new Buffer(`${String(file.contents)}-1`);
				outputFile2.contents = new Buffer(`${String(file.contents)}-2`);

				this.push(outputFile1);
				this.push(outputFile2);

				cb(null);
			});

			const pushedFilesCount = 2;

			const targetFile = new File({
				contents: new Buffer('abufferwiththiscontent')
			});

			fakeTask = through.obj(updatedFileHandler);

			const opts = {
				value:   sandbox.spy(cache.defaultOptions.value),
				restore: sandbox.spy(cache.defaultOptions.restore)
			};

			// Create a proxied plugin stream
			let proxied = cache(fakeTask, opts),
				count = 0;

			cacheStep();
github jgable / gulp-cache / src / task-proxy.js View on Github external
cachedValuesWithNormalPaths.forEach((cachedFile) => {
				// Extend the cached value onto the file, but don't overwrite original path info
				const file = new File({
					// custom properties
					...cachedFile,
					// file info
					...pick(inputFile, ['cwd', 'base', 'stat', 'history', 'path']),
					// file contents
					contents: cachedFile.contents
				});

				// Restore the file path if it was set
				if (cachedFile.path && cachedFile.gulpCache$filePathChangedInsideTask) {
					file.path = cachedFile.path;
				}

				// Restore the file base if it was set
				if (cachedFile.base && cachedFile.gulpCache$fileBaseChangedInsideTask) {
					file.base = cachedFile.base;
github shannonmoeller / gulp-hb / test / gulp-hb.js View on Github external
test.cb('should not render a stream', t => {
	const stream = gulpHb();

	stream.on('error', error => {
		t.is(error.message, 'Streaming not supported.');
		t.end();
	});

	stream.write(new File({
		base: __dirname,
		path: path.join(__dirname, 'fixture', 'fixture.js'),
		contents: new Readable()
	}));
});
github laget-se / react-gettext-parser / src / gulp.js View on Github external
function write(cb) {
    allMessages = getUniqueBlocks(allMessages)

    const potFile = new Vinyl({
      base: process.cwd(),
      path: options.output,
      contents: Buffer.from(toPot(allMessages)),
    })

    this.push(potFile)

    console.log(`Writing .pot file to ${options.output}`.green)

    cb()
  }
github wechat-miniprogram / miniprogram-i18n / packages / gulp-i18n-locales / index.ts View on Github external
const localeString = JSON.stringify(localeFile)
    const defaultLocale = options && options.defaultLocale || DEFAULT_LOCALE
    const fallbackLocale = options && options.fallbackLocale || DEFAULT_FALLBACK_LOCALE
    const wxsContent = `var fallbackLocale='${fallbackLocale}';var translations=${localeString};\n${getWxsCode()}`

    const jsContent = `module.exports.fallbackLocale='${fallbackLocale}';module.exports.defaultLocale='${defaultLocale}';module.exports.translations=${localeString};`

    const wxsFile = new File({
      cwd: firstFile.cwd,
      base: firstFile.base,
      path: path.join(firstFile.base, wxsFileName),
      contents: Buffer.from(wxsContent),
    })

    const jsFile = new File({
      cwd: firstFile.cwd,
      base: firstFile.base,
      path: path.join(firstFile.base, jsFileName),
      contents: Buffer.from(jsContent),
    })

    this.push(wxsFile)
    this.push(jsFile)
    cb()
  }
github Fitbit / fitbit-sdk-toolchain / src / appPackageManifest.ts View on Github external
sourceMaps: this.sourceMaps,
        manifestVersion: 6,
        ...(setSDKVersion && {
          sdkVersion: {
            ...(this.components.watch && this.hasJS && { deviceApi }),
            ...(this.components.companion && { companionApi }),
          },
        }),
        requestedPermissions: this.projectConfig.requestedPermissions,
        appId: this.projectConfig.appUUID,
      },
      undefined,
      2,
    );
    this.push(
      new Vinyl({
        contents: Buffer.from(manifestJSON, 'utf8'),
        path: path.resolve(process.cwd(), manifestPath),
      }),
    );
    callback();
  }
}
github Fitbit / fitbit-sdk-toolchain / src / rollupToVinyl.ts View on Github external
function emitAsset({ fileName, source }: rollup.OutputAsset) {
    stream.push(
      new Vinyl({
        contents: Buffer.isBuffer(source)
          ? source
          : Buffer.from(source, 'utf8'),
        path: resolve(process.cwd(), generatePath(fileName)),
      }),
    );
  }
github triplecanopy / b-ber / src / tasks / opf / manifest-metadata.jsx View on Github external
new Promise((resolve, reject) => {
    const metadata = renderLayouts(new File({
      path: './.tmp',
      layout: 'opfMetadata',
      contents: new Buffer(resp.bookmeta.join(''))
    }), tmpl.opf).contents.toString()

    const manifest = renderLayouts(new File({
      path: './.tmp',
      layout: 'opfManifest',
      contents: new Buffer(cjoin(resp.manifest))
    }), tmpl.opf).contents.toString()

    resolve({ metadata, manifest })
  })
github triplecanopy / b-ber / packages / b-ber-templates / src / Xhtml / index.js View on Github external
static stylesheet(inline = false) {
    return inline
      ? new File({ contents: Buffer.from('<style>{% body %}</style>') })
      : new File({
          contents: Buffer.from(
            ''
          ),
        })
  }
github triplecanopy / b-ber / src / bber-templates / opf / index.es6 View on Github external
xml:lang="en"
      unique-identifier="uuid"
      xmlns="http://www.idpf.org/2007/opf"
      xmlns:dc="http://purl.org/dc/elements/1.1/"
      xmlns:dcterms="http://purl.org/dc/terms/"
      prefix="ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/"&gt;
      {% body %}
    `),
})

const opfMetadata = new File({
  path: 'opfMetadata.tmpl',
  contents: new Buffer(''),
})

const opfManifest = new File({
  path: 'opfManifest.tmpl',
  contents: new Buffer('{% body %}'),
})

const opfSpine = new File({
  path: 'opfSpine.tmpl',
  contents: new Buffer('{% body %}'),
})

const opfGuide = new File({
  path: 'opfGuide.tmpl',
  contents: new Buffer('{% body %}'),
})

const manifestItem = (file) =&gt; {
  const props = Props.testHTML(file)

vinyl

Virtual file format.

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis