How to use the broccoli-plugin.prototype function in broccoli-plugin

To help you get started, we’ve selected a few broccoli-plugin 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 Shopify / js-buy-sdk / build-lib / util / lokka-builder.js View on Github external
}
    ]
  });
}

function LokkaBuilder(options) {
  const defaultedOptions = options || {};

  Plugin.call(this, [/* takes no input nodes */], {
    annotation: defaultedOptions.annotation
  });

  this.options = defaultedOptions;
}

LokkaBuilder.prototype = Object.create(Plugin.prototype);
LokkaBuilder.prototype.constructor = LokkaBuilder;

LokkaBuilder.prototype.build = function () {
  return Promise.all([
    bundleLokka(),
    bundleLokkaTransport()
  ]).then(bundles => {
    const lokka = bundles[0];
    const lokkaTransportHttp = bundles[1];

    return Promise.all([lokka.write({
      format: 'es',
      exports: 'named',
      dest: path.join(this.outputPath, 'lokka.js')
    }), lokkaTransportHttp.write({
      format: 'es',
github isleofcode / ember-cli-asset-sizes-shim / lib / plugins / tree-stats.js View on Github external
var Plugin = require("broccoli-plugin");
var path = require("path");
var fs = require("fs");
var Promise = require("rsvp").Promise; // jshint ignore:line
var makeDir = require("../helpers/make-dir");
var analyze = require('../helpers/analyze-path');
var chalk = require('chalk');

// Create a subclass from Plugin
TreeStats.prototype = Object.create(Plugin.prototype);
TreeStats.prototype.constructor = TreeStats;

function TreeStats(inputNodes, options) {
  options = options || {
      annotation: "Vendor Stats"
    };
  this.options = options;

  Plugin.call(this, inputNodes, {
    annotation: options.annotation
  });
}

TreeStats.prototype.build = function () {
  var _self = this;
  var builtAll = [];
github timmfin / broccoli-webpack-cached / index.js View on Github external
var PreventResolveSymlinkPlugin = require('./prevent-resolve-symlink-plugin');

function WebpackFilter(inputNode, options) {
  if (!(this instanceof WebpackFilter)) return new WebpackFilter(inputNode, options);

  if (Array.isArray(inputNode)) {
    throw new Error("WebpackFilter only accepts a single inputNode");
  }

  Plugin.call(this, [inputNode], {
    annotation: options.annotation
  });
  this.options = options;
}

WebpackFilter.prototype = Object.create(Plugin.prototype);
WebpackFilter.prototype.constructor = WebpackFilter;


// "private" helpers

function ensureArray(potentialArray) {
  if (typeof potentialArray === 'string') {
    return [potentialArray];
  } else {
    return potentialArray || [];
  }
}


WebpackFilter.prototype.initializeCompiler = function() {
  if (this.options.context) throw new Error("WebpackFilter will set the webpack context, you shouldn't set it.");
github glimmerjs / glimmer-application-pipeline / lib / broccoli / module-map-creator.js View on Github external
const Plugin = require('broccoli-plugin');
const fs = require('fs');
const path = require('path');
const walkSync = require('walk-sync');
const getModuleConfig = require('./get-module-config');

function ModuleMapCreator(src, config, options) {
  options = options || {};
  Plugin.call(this, [src, config], {
    annotation: options.annotation
  });
  this.options = options;
}

ModuleMapCreator.prototype = Object.create(Plugin.prototype);
ModuleMapCreator.prototype.constructor = ModuleMapCreator;
ModuleMapCreator.prototype.build = function() {
  function specifierFromModule(modulePrefix, moduleConfig, modulePath) {
    let path;
    let collectionPath;

    for (let i = 0, l = moduleConfig.collectionPaths.length; i < l; i++) {
      path = moduleConfig.collectionPaths[i];
      if (modulePath.indexOf(path) === 0) {
        collectionPath = path;
        break;
      }
    }

    if (collectionPath) {
      // trim group/collection from module path
github ebryn / ember-component-css / lib / include-all.js View on Github external
/* eslint-env node */
'use strict';

var Plugin = require('broccoli-plugin');
var walkSync = require('walk-sync');
var fs = require('fs');
var FSTree = require('fs-tree-diff');
var Promise = require('rsvp').Promise;
var path = require('path');
var os = require("os");

module.exports = IncludeAll;

IncludeAll.prototype = Object.create(Plugin.prototype);
IncludeAll.prototype.constructor = IncludeAll;
function IncludeAll(inputNode, options) {
  options = options || {};
  Plugin.call(this, [inputNode], {
    annotation: options.annotation,
    persistentOutput: true
  });

  this.currentTree = new FSTree();
  this.importedPods = {};
}

IncludeAll.prototype.build = function() {
  var srcDir = this.inputPaths[0];

  var entries = walkSync.entries(srcDir);
github ebryn / ember-component-css / lib / pod-names.js View on Github external
/* eslint-env node */
'use strict';

var Plugin = require('broccoli-plugin');
var walkSync = require('walk-sync');
var fs = require('fs');
var FSTree = require('fs-tree-diff');
var Promise = require('rsvp').Promise;
var path = require('path');
var componentNames = require('./component-names.js');

module.exports = PodNames;

PodNames.prototype = Object.create(Plugin.prototype);
PodNames.prototype.constructor = PodNames;
function PodNames(inputNode, options) {
  options = options || {};
  Plugin.call(this, [inputNode], {
    annotation: options.annotation,
    persistentOutput: true
  });

  this.currentTree = new FSTree();
  this.podNameJson = {};
  this.classicStyleDir = options.classicStyleDir;
  this.terseClassNames = options.terseClassNames;
}

PodNames.prototype.build = function() {
  var srcDir = this.inputPaths[0];
github ef4 / ember-browserify / lib / stub-generator.js View on Github external
if (Array.isArray(inputTree) || !inputTree) {
    throw new Error('Expects one inputTree');
  }

  Plugin.call(this, [inputTree], options);
  this._persistentOutput = true;

  // setup persistent state
  this._previousTree = new FSTree();
  this.stubs = new Stubs();

  this._fileToChecksumMap = {};
}

StubGenerator.prototype = Object.create(Plugin.prototype);
StubGenerator.prototype.constructor = StubGenerator;
StubGenerator.prototype.build = function() {
  var start = Date.now();
  var inputPath = this.inputPaths[0];
  var previous  = this._previousTree;

  // get patchset
  var input = walkSync.entries(inputPath, [ '**/*.js' ]);

  debug('input: %d', input.length);

  var next = this._previousTree = FSTree.fromEntries(input);
  var patchset = previous.calculatePatch(next);

  debug('patchset: %d', patchset.length);
github ember-cli / ember-cli / tests / fixtures / brocfile-tests / multiple-sass-files / node_modules / broccoli-sass / index.js View on Github external
dirs.unshift(destDir);
      destDir = path.dirname(destDir);
    }
    dirs.forEach(function (dir) {
      fs.mkdirSync(dir);
    });
    var content = fs.readFileSync(src);
    fs.writeFileSync(dest, content, { flag: 'wx' });
    fs.utimesSync(dest, srcStats.atime, srcStats.mtime);
  } else {
    throw new Error('Unexpected file type for ' + src);
  }
}

module.exports = SassCompiler;
SassCompiler.prototype = Object.create(Plugin.prototype);
SassCompiler.prototype.constructor = SassCompiler;
function SassCompiler (inputNodes, inputFile, outputFile, options) {
  if (!(this instanceof SassCompiler)) return new SassCompiler(inputNodes, inputFile, outputFile, options);
  Plugin.call(this, inputNodes);
  this.inputFile = inputFile;
  this.outputFile = outputFile;
}

SassCompiler.prototype.build = function () {
  copyPreserveSync(
    path.join(this.inputPaths[0], this.inputFile),
    path.join(this.outputPath, this.outputFile));
};
github ember-cli / broccoli-caching-writer / index.js View on Github external
'use strict';

var fs = require('fs');
var RSVP = require('rsvp');
var rimraf = RSVP.denodeify(require('rimraf'));
var helpers = require('broccoli-kitchen-sink-helpers');
var Plugin = require('broccoli-plugin');
var debugGenerator = require('debug');
var Key = require('./key');
var canUseInputFiles = require('./can-use-input-files');
var walkSync = require('walk-sync');

CachingWriter.prototype = Object.create(Plugin.prototype);
CachingWriter.prototype.constructor = CachingWriter;
function CachingWriter (inputNodes, options) {
  options = options || {};

  Plugin.call(this, inputNodes, {
    name: options.name,
    annotation: options.annotation,
    persistentOutput: true
  });

  this._cachingWriterPersistentOutput = !!options.persistentOutput;

  this._lastKeys = null;
  this._shouldBeIgnoredCache = Object.create(null);
  this._resetStats();
github robwebdev / ember-cli-staticboot / lib / broccoli / staticboot.js View on Github external
const Plugin = require('broccoli-plugin');
const mkdirp = require('mkdirp');
const getDirName = require('path').dirname;
const path = require('path');

function StaticBootBuild(inputTree, options) {
  options = options || {};
  if(!(this instanceof StaticBootBuild)) {
    return new StaticBootBuild(inputTree, options);
  }
  Plugin.call(this, [inputTree]);
  this.paths = options.paths || [];
  this.inputTree = inputTree;
}

StaticBootBuild.prototype = Object.create(Plugin.prototype);
StaticBootBuild.prototype.constructor = StaticBootBuild;

StaticBootBuild.prototype.build = function () {
  var srcDir = this.inputPaths[0];
  var destDir = this.outputPath;

  const app = new FastBoot({
    distPath: srcDir,
    resilient: true
  });

  const buildStaticPage = this.buildStaticPage(app, destDir);
  const promises = this.paths.map(path => buildStaticPage(path));
  return RSVP.all(promises);
};

broccoli-plugin

Base class for all Broccoli plugins

MIT
Latest version published 4 years ago

Package Health Score

62 / 100
Full package analysis

Popular broccoli-plugin functions