How to use the vinyl.prototype 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 amtrack / force-dev-tool / lib / metadata-file.js View on Github external
var config = new(require("./config"))();
var folderToMetadataType = config.get("folderBasedMetadataMap");
var metadataTypeToFolder = _.invert(folderToMetadataType);

/**
 * MetadataFile represents a file on the filesystem.
 * It inherits from vinyl.
 * Note that the path should be relative to `src`.
 */

var MetadataFile = module.exports = function(opts) {
	File.call(this, opts);
};

MetadataFile.prototype = Object.create(File.prototype);
MetadataFile.prototype.constructor = MetadataFile;

MetadataFile.prototype.basenameDirname = function() {
	var self = this;
	return path.basename(path.dirname(self.path));
};

MetadataFile.prototype.waveTemplateDirname = function() {
	// Metadata like WaveTemplateBundles are deeply nested and contain ambiguous subfolders like 'dashboard'.
	var self = this;
	var pathComponents = self.path.split(path.sep);
	return pathComponents[1];
};

MetadataFile.prototype.parentDirname = function() {
	var self = this;
github max-team / Mars / packages / mars-build / src / gulp-mars-h5.js View on Github external
const compilers = {
    templateCompiler,
    styleCompiler,
    scriptPostCompiler,
    scriptCompiler,
    configCompiler
};

// const delToVueTag = require('./h5/transform/tag');
// // const generate = require('./compiler/template/generate');

let componentSet = {}; // 小程序使用的组件集合
// let mainOptions = {}; // 配置集合
let pagesInfo = {}; // 页面title集合

Vinyl.prototype.writeFileSync = function () {
    if (!this.contents || !this.path) {
        throw new Error('Vinyl.prototype.writeFileSync() requires path and contents to write');
    }

    fs.writeFileSync(this.path, this.contents.toString());
};


// /**
//  * @file gulp plugin
//  * @author zhangwentao 
//  */
// /* eslint-disable fecs-min-vars-per-destructure */
// const renderFunctionName = '__renderFunction';
// const {getFileCompilers} = require('../file/base');
github max-team / Mars / packages / mars-build / src / compiler / sfc / File.js View on Github external
/* eslint-disable no-native-reassign */

/* eslint-disable fecs-min-vars-per-destructure */

const Vinyl = require('vinyl');
const fs = require('fs-extra');

Vinyl.prototype.writeFileSync = function () {
    if (!this.contents || !this.path) {
        throw new Error('Vinyl.prototype.writeFileSync() requires path and contents to write');
    }

    fs.outputFileSync(this.path, this.contents.toString());
};

Vinyl.prototype.appendContent = function (str) {
    const content = this.contents ? this.contents.toString() : '';
    this.contents = Buffer.from(content + str);
};

module.exports = Vinyl;
github max-team / Mars / packages / mars-build / src / compiler / sfc / File.js View on Github external
/**
 * @file gulp plugin
 * @author zhangwentao 
 */

/* eslint-disable fecs-no-require */

/* eslint-disable no-native-reassign */

/* eslint-disable fecs-min-vars-per-destructure */

const Vinyl = require('vinyl');
const fs = require('fs-extra');

Vinyl.prototype.writeFileSync = function () {
    if (!this.contents || !this.path) {
        throw new Error('Vinyl.prototype.writeFileSync() requires path and contents to write');
    }

    fs.outputFileSync(this.path, this.contents.toString());
};

Vinyl.prototype.appendContent = function (str) {
    const content = this.contents ? this.contents.toString() : '';
    this.contents = Buffer.from(content + str);
};

module.exports = Vinyl;
github assemble / assemble / test / app.create.js View on Github external
it('should create views from custom `View` and `Views` instance/ctor:', function() {
      var Vinyl = require('vinyl');
      Vinyl.prototype.read = function(file) {
        return fs.readFileSync(file.path);
      };

      var Views = App.Views;
      var views = new Views({View: Vinyl});

      views.addView('a.hbs', {path: 'a.hbs', content: 'a'});
      views.addView('b.hbs', {path: 'b.hbs', content: 'b'});
      views.addView('c.hbs', {path: 'c.hbs', content: 'c'});

      app = new App();
      app.create('pages', views);

      var a = app.pages.getView('a.hbs');
      assert(a instanceof Vinyl);
      assert(Vinyl.isVinyl(a));
github generate / generate / test / app.create.js View on Github external
it('should create views from custom `View` and `Views` instance/ctor:', function() {
      var Vinyl = require('vinyl');
      Vinyl.prototype.read = function(file) {
        return fs.readFileSync(file.path);
      };

      var Views = App.Views;
      var views = new Views({View: Vinyl});

      views.addView('a.hbs', {path: 'a.hbs', content: 'a'});
      views.addView('b.hbs', {path: 'b.hbs', content: 'b'});
      views.addView('c.hbs', {path: 'c.hbs', content: 'c'});

      app = new App();
      app.create('pages', views);

      var a = app.pages.getView('a.hbs');
      assert(a instanceof Vinyl);
      assert(Vinyl.isVinyl(a));
github jonschlinkert / templates / test / app.create.js View on Github external
beforeEach(function() {
        var Vinyl = require('vinyl');
        Vinyl.prototype.custom = function(key) {
          this[key] = 'nonsense';
          return this;
        };
        app = new App({View: Vinyl});
        app.create('pages');
      });
github generate / generate / test / app.create.js View on Github external
beforeEach(function() {
      var Vinyl = require('vinyl');
      Vinyl.prototype.custom = function(key) {
        this[key] = 'nonsense';
        return this;
      };
      app = new App({View: Vinyl});
      app.create('pages');
    });
github update / update / test / app.create.js View on Github external
beforeEach(function() {
      var Vinyl = require('vinyl');
      Vinyl.prototype.custom = function(key) {
        this[key] = 'nonsense';
        return this;
      };
      app = new App({View: Vinyl});
      app.create('pages');
    });
github verbose / verb / test / app.create.js View on Github external
beforeEach(function() {
      var Vinyl = require('vinyl');
      Vinyl.prototype.custom = function(key) {
        this[key] = 'nonsense';
        return this;
      };
      app = new App({View: Vinyl});
      app.create('pages');
    });

vinyl

Virtual file format.

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis