Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

borschik

Package Overview
Dependencies
Maintainers
5
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

borschik - npm Package Compare versions

Comparing version 0.2.8 to 0.3.0

.jshintignore

36

lib/coa.js

@@ -48,2 +48,38 @@ var Q = require('q'),

.end()
.opt()
.name('comments').title('Wrap included files with comments (default: yes)')
.short('c').long('comments')
.def(true)
.val(function(v) {
return U.stringToBoolean(v, true);
})
.end()
// borschik freeze
.cmd()
.name('freeze')
.title('Freeze all files in dirs according to .borschik config')
.helpful()
.opt()
.name('input').title('Input path (default: .).')
.short('i').long('input')
.def('.')
.end()
.opt()
.name('output').title('Output path for resulting JSON')
.short('o').long('output')
.output()
.end()
.opt()
.name('minimize').title('Minimize resulting JSON (default: yes)')
.short('m').long('minimize')
.def(true)
.val(function(v) {
return U.stringToBoolean(v, true);
})
.end()
.act(function(opts) {
var result = require('./freeze').freezeAll(opts.input);
return U.writeFile(opts.output, opts.minimize? JSON.stringify(result) : JSON.stringify(result, null, 4));
})
.end()
.act(function(opts) {

@@ -50,0 +86,0 @@

@@ -109,2 +109,64 @@ var CRYPTO = require('crypto'),

/**
* Recursivly freeze all files in path.
* @param {String} input File or directory path
*/
exports.freezeAll = function(input) {
/**
* Result JSON
* @type {Object}
*/
var result = {};
var basePath = PATH.dirname(input);
var stat = FS.statSync(input);
if (stat.isFile()) {
freezeAllProcessFile(input, process.cwd(), result);
} else if (stat.isDirectory()) {
freezeAllProcessDir(input, basePath, result);
}
return result;
};
/**
* Process file: freeze and write meta-data to result JSON
* @param absPath
* @param basePath
* @param {Object} result Result JSON
*/
function freezeAllProcessFile(absPath, basePath, result) {
var url = absPath;
if (freezableRe.test(url) || /\.(?:css|js|swf)$/.test(url)) {
url = freeze(url);
}
var relOriginalPath = PATH.relative(basePath, absPath);
var resolved = resolveUrl2(url);
url = (resolved == url ? PATH.relative(basePath, url) : resolved);
result[relOriginalPath] = url;
}
/**
* Read dir recursivly and process files
* @param dir
* @param basePath
* @param {Object} result Result JSON
*/
function freezeAllProcessDir(dir, basePath, result) {
FS.readdirSync(dir).forEach(function(file) {
file = PATH.resolve(dir, file);
var stat = FS.statSync(file);
if (stat.isFile()) {
freezeAllProcessFile(file, basePath, result);
} else if (stat.isDirectory()) {
freezeAllProcessDir(file, basePath, result);
}
});
}
/**
* Get path from "path" config by path if any.

@@ -111,0 +173,0 @@ *

6

lib/techs/css-base.js

@@ -25,3 +25,3 @@ var INHERIT = require('inherit'),

if (this.tech.opts.freeze && FREEZE.isFreezableUrl(url)) {
if (this.tech.opts.freeze && this.isFreezableUrl(url)) {
url = FREEZE.processPath(url);

@@ -35,2 +35,6 @@ }

return JSON.stringify(url);
},
isFreezableUrl: function(url) {
return FREEZE.isFreezableUrl(url);
}

@@ -37,0 +41,0 @@

5

lib/techs/css.js

@@ -67,5 +67,6 @@ var INHERIT = require('inherit'),

if (item.type === 'include') {
parsed[i] = '/* ' + item.url + ' begin */\n' +
var comments = this.tech.opts.comments;
parsed[i] = (comments ? '/* ' + item.url + ' begin */\n' : '') +
this.child('include', item.url).process(path) +
'\n/* ' + item.url + ' end */\n';
(comments ? '\n/* ' + item.url + ' end */\n' : '');

@@ -72,0 +73,0 @@ continue;

@@ -70,5 +70,13 @@ var INHERIT = require('inherit'),

var processed = this.child('include', item.file).process(baseFile);
parsed[i] = (item.type === 'comment'?
commentsWrap(processed, PATH.relative(PATH.dirname(baseFile), item.file)) :
JSON.stringify(processed));
var result;
if (item.type === 'comment') {
if (this.tech.opts.comments) {
result = commentsWrap(processed, PATH.relative(PATH.dirname(baseFile), item.file));
} else {
result = processed;
}
} else {
result = JSON.stringify(processed);
}
parsed[i] = result;
}

@@ -75,0 +83,0 @@

{
"name": "borschik",
"description": "Extendable builder for text-based file formats",
"version": "0.2.8",
"version": "0.3.0",
"homepage": "http://github.com/veged/borschik",

@@ -6,0 +6,0 @@ "author": "Sergey Berezhnoy <veged@ya.ru> (http://github.com/veged)",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc