Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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');
/* 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;
/**
* @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;
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));
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));
beforeEach(function() {
var Vinyl = require('vinyl');
Vinyl.prototype.custom = function(key) {
this[key] = 'nonsense';
return this;
};
app = new App({View: Vinyl});
app.create('pages');
});
beforeEach(function() {
var Vinyl = require('vinyl');
Vinyl.prototype.custom = function(key) {
this[key] = 'nonsense';
return this;
};
app = new App({View: Vinyl});
app.create('pages');
});
beforeEach(function() {
var Vinyl = require('vinyl');
Vinyl.prototype.custom = function(key) {
this[key] = 'nonsense';
return this;
};
app = new App({View: Vinyl});
app.create('pages');
});
beforeEach(function() {
var Vinyl = require('vinyl');
Vinyl.prototype.custom = function(key) {
this[key] = 'nonsense';
return this;
};
app = new App({View: Vinyl});
app.create('pages');
});