New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

buildman

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buildman - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

tests/example-min.js

89

index.js
process.chdir( process.env.PWD )
var exec = require('child_process').exec
var spawn = require("child_process").spawn
, fs = require('fs')
var fs = require('fs')
, conf = require( process.env.PWD + '/package.json') || {}

@@ -11,8 +8,9 @@

function callmin(file, min_file, next) {
if (typeof file == 'string') file = [file]
function prepare_options(args) {
if (typeof args.input == 'string') args.input = [args.input]
var newestSource = 0
var newest = 0
file.forEach(function(name, i, arr){
args.input.forEach(function(name, i, arr){
if (!fs.existsSync(name)) {

@@ -22,18 +20,26 @@ name = arr[i] = require.resolve(name)

var stat = fs.statSync(name)
if (newestSource < stat.mtime) newestSource = stat.mtime
if (newest < +stat.mtime) newest = stat.mtime
})
if (newestSource < fs.statSync(min_file).mtime) return next && next();
if (fs.existsSync(args.output) && newest < fs.statSync(args.output).mtime) {
args.next && args.next()
return true
}
console.log("# Build "+min_file)
console.log("# Build " + args.output)
}
function callmin(args) {
if (prepare_options(args)) return
var http = require('http')
, querystring = require('querystring')
, fileString = file.map(function(name){
, fileString = args.input.map(function(name){
return fs.readFileSync(name, 'utf8')
}).join('\n')
if (file.length > 1) {
fs.writeFileSync(min_file.replace('.js', '-src.js'), fileString);
if (args.input.length > 1) {
fs.writeFileSync(args.output.replace('.js', '-src.js'), fileString);
}

@@ -71,7 +77,5 @@

var compiledCode = JSON.parse(text).compiledCode;
fs.writeFileSync(min_file, compiledCode);
fs.writeFileSync(args.output, compiledCode);
if (file == conf.main) {
}
next && next()
args.next && args.next()
})

@@ -86,4 +90,20 @@ });

exports.callmin = callmin
function min_html(args) {
if (prepare_options(args)) return
var minify = require("html-minifier").minify;
var input = args.input.map(function(name){
return fs.readFileSync(name, 'utf8')
}).join('\n')
var output = minify(input, {
removeComments: true,
collapseWhitespace: true});
fs.writeFileSync(args.output, output);
args.next && args.next()
}
function buildAll() {

@@ -93,3 +113,12 @@ var min = Object.keys(conf.buildman || {})

min.forEach(function(file){
callmin(conf.buildman[file], file)
var args = {
input: conf.buildman[file],
output: file
}
switch (file.split(".").pop()) {
case "js": callmin(args); break;
case "html": min_html(args); break;
default:
console.error("Unknown type "+file)
}
})

@@ -107,5 +136,15 @@

for (var i = 2, val; val = process.argv[i++]; ) {
;( map[val] || invalidTarget )(val)
};
if (module.parent) {
// Used as module
exports.callmin = callmin
exports.min_html = min_html
} else {
// executed as standalone
for (var i = 2, val; val = process.argv[i++]; ) {
;( map[val] || invalidTarget )(val)
};
}
{
"name": "buildman",
"version": "0.0.4",
"description": "Expiremental webapp bundler",
"main": "index.js",
"scripts": {
"test": "node tests/run.js"
},
"repository": {
"type": "git",
"url": "git://github.com/lauriro/buildman.git"
},
"keywords": [
"readme"
],
"author": "Lauri Rooden <lauri@rooden.ee>",
"license": "MIT",
"devDependencies": {
"testman": "*"
},
"bugs": {
"url": "https://github.com/lauriro/buildman/issues"
}
"name": "buildman",
"version": "0.0.5",
"description": "Expiremental webapp bundler",
"main": "index.js",
"scripts": {
"test": "node tests/run.js"
},
"repository": {
"type": "git",
"url": "git://github.com/lauriro/buildman.git"
},
"keywords": [
"readme"
],
"author": "Lauri Rooden <lauri@rooden.ee>",
"license": "MIT",
"devDependencies": {
"testman": "*"
},
"bugs": {
"url": "https://github.com/lauriro/buildman/issues"
},
"dependencies": {
"html-minifier": "~0.5.4"
}
}
var buildman = require("../")
, fs = require('fs')
, testfile = "tests/test-min.js"
, testfile = "tests/min.js"

@@ -11,3 +11,7 @@ require("testman").

console.log("# run 1")
buildman.callmin(["dummy"], testfile, this.wait() )
buildman.callmin({
input: ["dummy"],
output: testfile,
next: this.wait()
})
}).

@@ -19,7 +23,7 @@ run(function(){

function(){
console.log("# run 3")
console.log("# run 3")
return ""+fs.readFileSync(testfile)
},
function(){
return ""+fs.readFileSync("tests/target-min.js")
return ""+fs.readFileSync("tests/example-min.js")
}

@@ -30,2 +34,19 @@ ).

}).
it( "should minimize html", {skip: "not completed"} ).
run(function(){
buildman.min_html({
input: "tests/test.html",
output: "tests/test-min.html",
next: this.wait()
})
}).
equal(
function(){
console.log("# run 3")
return ""+fs.readFileSync("tests/test.html")
},
function(){
return ""+fs.readFileSync("tests/test-min.html")
}
).
done()
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