broccoli-file-creator
Advanced tools
Comparing version 1.2.0 to 2.0.0
63
index.js
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Plugin = require('broccoli-plugin'); | ||
var mkdirp = require('mkdirp'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const Plugin = require('broccoli-plugin'); | ||
const mkdirp = require('mkdirp'); | ||
module.exports = Creator; | ||
Creator.prototype = Object.create(Plugin.prototype); | ||
Creator.prototype.constructor = Creator; | ||
module.exports = function(filename, content, options) { | ||
return new Creator(filename, content, options); | ||
}; | ||
function Creator (filename, content, _options) { | ||
var options = _options || { | ||
encoding: 'utf8' | ||
}; | ||
class Creator extends Plugin { | ||
constructor (filename, content, _options) { | ||
const options = _options || { | ||
encoding: 'utf8' | ||
}; | ||
if (!(this instanceof Creator)) { | ||
return new Creator(filename, content, options); | ||
} | ||
super([], { | ||
annotation: options.annotation || constructor.name + filename, | ||
persistentOutput: true | ||
}); | ||
Plugin.call(this, [/* no inputTrees */], { | ||
annotation: options.annotation || this.constructor.name + ' ' + filename, | ||
persistentOutput: true | ||
}); | ||
this.content = content; | ||
this.filename = filename; | ||
this.fileOptions = options; | ||
delete options.annotation; | ||
this._built = false; | ||
} | ||
this.content = content; | ||
this.filename = filename; | ||
this.fileOptions = options; | ||
build() { | ||
if (this._built) { | ||
return; | ||
} | ||
this._built = false; | ||
} | ||
const outputFilePath = path.join(this.outputPath, this.filename); | ||
mkdirp.sync(path.dirname(outputFilePath)); | ||
fs.writeFileSync(outputFilePath, this.content, this.fileOptions); | ||
Creator.prototype.build = function () { | ||
if (this._built) { | ||
return; | ||
this._built = true; | ||
} | ||
}; | ||
var outputFilePath = path.join(this.outputPath, this.filename); | ||
mkdirp.sync(path.dirname(outputFilePath)); | ||
fs.writeFileSync(outputFilePath, this.content, this.fileOptions); | ||
this._built = true; | ||
}; | ||
module.exports.Class = Creator; |
{ | ||
"name": "broccoli-file-creator", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"description": "Broccoli plugin to create a file.", | ||
@@ -32,3 +32,6 @@ "main": "index.js", | ||
"rimraf": "~2.2.6" | ||
}, | ||
"engines": { | ||
"node": "^4.5 || 6.* || >= 7.*" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3507
33