Socket
Socket
Sign inDemoInstall

broccoli-file-creator

Package Overview
Dependencies
25
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.1.0

34

index.js

@@ -12,7 +12,13 @@ var fs = require('fs');

function Creator (filename, content, _options) {
if (!(this instanceof Creator)) return new Creator(filename, content, options);
var options = _options || { encoding: 'utf8' };
var options = _options || {
encoding: 'utf8'
};
if (!(this instanceof Creator)) {
return new Creator(filename, content, options);
}
Plugin.call(this, [/* no inputTrees */], {
annotation: options.annotation || this.constructor.name + ' ' + filename
annotation: options.annotation || this.constructor.name + ' ' + filename,
persistentOutput: true
});

@@ -25,22 +31,14 @@

this.fileOptions = options;
};
}
Creator.prototype.build = function () {
var cacheFilePath = path.join(this.cachePath, this.filename);
var outputFilePath = path.join(this.outputPath, this.filename);
writeToCache(cacheFilePath, this.content, this.fileOptions);
linkFromCache(cacheFilePath, outputFilePath);
};
if (fs.existsSync(outputFilePath)) {
return;
}
function writeToCache(cacheFilePath, content, options) {
if (fs.existsSync(cacheFilePath)) { return; }
mkdirp.sync(path.dirname(cacheFilePath));
fs.writeFileSync(cacheFilePath, content, options);
}
mkdirp.sync(path.dirname(outputFilePath));
function linkFromCache(from, to) {
mkdirp.sync(path.dirname(to));
symlinkOrCopySync(from, to);
}
fs.writeFileSync(outputFilePath, this.content, this.fileOptions);
};
{
"name": "broccoli-file-creator",
"version": "1.0.1",
"version": "1.1.0",
"description": "Broccoli plugin to create a file.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -41,2 +41,5 @@ 'use strict';

function read(path) {
return fs.readFileSync(path, 'UTF8');
}
it('creates the file specified', function(){

@@ -49,3 +52,3 @@ var content = 'ZOMG, ZOMG, HOLY MOLY!!!';

return builder.build().then(function(result) {
expect(fs.readFileSync(result.directory + '/something.js', {encoding: 'utf8'})).to.eql(content);
expect(read(result.directory + '/something.js')).to.eql(content);
});

@@ -61,3 +64,3 @@ });

return builder.build().then(function(result) {
expect(fs.readFileSync(result.directory + '/somewhere/something.js', {encoding: 'utf8'})).to.eql(content);
expect(read(result.directory + '/somewhere/something.js')).to.eql(content);
});

@@ -73,8 +76,7 @@ });

var stat;
return builder.build().then(function(result) {
stat = fs.lstatSync(result.directory + '/something.js');
debugger;
return builder.build();
}).then(function(result){
stat;
var newStat = fs.lstatSync(result.directory + '/something.js');

@@ -81,0 +83,0 @@

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