Socket
Socket
Sign inDemoInstall

broccoli-plugin

Package Overview
Dependencies
40
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.1.0

4

CHANGELOG.md
# master
# 3.1.0
- Add `this.input` and `this.ouput` to broccoli-plugin instances, this aims to replace nearly all usage of `this.inputPaths` and `this.outputPath`. See the `Readme` for further details
# 3.0.0

@@ -4,0 +8,0 @@

import { InputNode, TransformNode, TransformNodeInfo, FeatureSet, CallbackObject } from 'broccoli-node-api';
import { MapSeriesIterator, PluginOptions } from './interfaces';
import { FSOutput } from 'broccoli-output-wrapper';
import FSMerger = require('fs-merger');
declare class Plugin implements TransformNode {

@@ -36,2 +38,4 @@ private _name;

readonly outputPath: string;
readonly input: FSMerger.FS;
readonly output: FSOutput;
private _checkOverrides;

@@ -38,0 +42,0 @@ __broccoliGetInfo__(builderFeatures?: FeatureSet): TransformNodeInfo;

"use strict";
const read_compat_1 = require("./read_compat");
const buildOutputWrapper = require("broccoli-output-wrapper");
const FSMerger = require("fs-merger");
const BROCCOLI_FEATURES = Object.freeze({

@@ -11,2 +13,3 @@ persistentOutputFlag: true,

const PATHS = new WeakMap();
const FSFACADE = new WeakMap();
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -93,2 +96,14 @@ function isPossibleNode(node) {

}
get input() {
if (!FSFACADE.has(this)) {
throw new Error('BroccoliPlugin: this.input is only accessible once the build has begun.');
}
return FSFACADE.get(this).input;
}
get output() {
if (!FSFACADE.has(this)) {
throw new Error('BroccoliPlugin: this.output is only accessible once the build has begun.');
}
return FSFACADE.get(this).output;
}
_checkOverrides() {

@@ -148,2 +163,6 @@ if (typeof this.rebuild === 'function') {

}
FSFACADE.set(this, {
input: new FSMerger(this._inputNodes).fs,
output: buildOutputWrapper(this),
});
}

@@ -150,0 +169,0 @@ toString() {

6

package.json
{
"name": "broccoli-plugin",
"version": "3.0.0",
"version": "3.1.0",
"description": "Base class for all Broccoli plugins",

@@ -27,2 +27,4 @@ "keywords": [

"broccoli-node-api": "^1.6.0",
"broccoli-output-wrapper": "^2.0.0",
"fs-merger": "^3.0.1",
"promise-map-series": "^0.2.1",

@@ -56,3 +58,3 @@ "quick-temp": "^0.1.3",

"rsvp": "^4.8.4",
"typescript": "^3.5.3"
"typescript": "^3.6.4"
},

@@ -59,0 +61,0 @@ "engines": {

@@ -24,7 +24,7 @@ # The Broccoli Plugin Base Class

// Read 'foo.txt' from the third input node
const input = fs.readFileSync(`${this.inputPaths[2]}/foo.txt`);
const input = this.input.readFileSync(`foo.txt`);
const output = someCompiler(input);
// Write to 'bar.txt' in this node's output
fs.writeFileSync(`${this.outputPath}/bar.txt`, output);
this.output.writeFileSync(`bar.txt`, output);
}

@@ -125,1 +125,80 @@ }

- `column`: Column in which the error occurred (zero-indexed)
### `Plugin.prototype.input`
An api which enables a plugin to easily read from one or more input directories ergonomically and safely.
_Note: We recommend users stop using this.inputPaths and instead rely on this.input. Our plan at present is to strongly consider deprecation of this.inputPaths once this.input has had time to bake._
this.input's features:
- `this.input` reads from the provided `inputPaths`. No path concatenation required.
- `this.input` provides readOnly file system APIs. This prevents a plugin from erroneously mutating its inputs.
- `this.input` provides a merged view of inputs, this allows every plugin to easily support multiple inputs, without the use of `broccoli-merge-trees` or implementing a complex merge algorithm.
- `this.input.at(index)` provides access to each individual input if desired.
Example:
```js
// old
fs.readFileSync(this.inputPaths[0] + '/file.txt');
// new (merged): Most Common
this.input.readFileSync('file.txt');
// new (indexed): For when you need to disambiguate between inputs.
this.input.at(0).readFileSync('file.txt);
// ReadOnly
this.input.writeFileSync // throws error
```
### List of Methods
- readFileSync
- existsSync
- lstatSync
- statSync
- readdirSync
- at
Read more about `input` [here](https://github.com/SparshithNR/fs-merger#fsmergerfs)
Note: `input` will be available only after the `build` starts.
### `Plugin.prototype.output`
An api which enables a plugin to easily write to the output directory ergonomically and safely.
_Note: We recommend users stop using this.outputPath and instead rely on this.output. Our plan at present is to strongly consider deprecation of this.outputPath once this.output has had time to bake._
this.output's features:
- `this.ouput` writes to the `outputPath`. No path concatenation required.
- `this.output` provides read operations on the `outputPath`. No path concatenation required.
Ex:
```js
// old
fs.writeFileSync(this.outputPath + '/file.txt', 'text');
// new
this.output.writeFileSync('file.txt', 'text');
```
### List of Methods
- readFileSync
- existsSync
- lstatSync
- readdirSync
- statSync
- writeFileSync
- appendFileSync
- rmdirSync
- mkdirSync
Read more about APIs present in `output` [here](https://github.com/SparshithNR/broccoli-output-wrapper#apis).
Note: `output` will be available only after the `build` starts.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc