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

crushit

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crushit - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

index.js

33

lib/main.js

@@ -6,4 +6,2 @@

"use strict";
var request = require('request'),

@@ -21,8 +19,6 @@ cheerio = require('cheerio'),

scripts: [],
scripts: [],
encoding: 'utf8',
directory: '',
filename: '',
minify: false,

@@ -44,3 +40,5 @@

if (!website || !opts.directory) {
if (!website) {
self.echoMsg('Error, you need to specify a web page resource');
return false;

@@ -50,4 +48,3 @@ }

self.processOptions(opts);
self.stream = uglify.OutputStream({beautify: opts.beautify});
self.filename = opts.directory + '/script_' + (new Date().getTime()) + '.js';
self.stream = uglify.OutputStream({beautify: opts.beautify});

@@ -67,8 +64,10 @@ self.loadWebPage(function (err) {

onComplete: function () {
var self = this, code = self.stream.toString();
onComplete: function (code) {
var self = this, filename;
filename = self.directory + '/script_' + (new Date().getTime()) + '.js';
if (code) {
fs.writeFile(self.filename, code, self.encoding, function () {
self.echoMsg('Success!! Scripts compiled and saved in ' + self.getFileName(self.filename));
fs.writeFile(filename, code, 'utf8', function () {
self.echoMsg('Success!! Scripts compiled and saved in ' + self.getFileName(filename));
});

@@ -188,7 +187,9 @@ }

loadScripts: function () {
var self = this, ast, script;
var self = this, ast, script, code;
// let us check if we have any scripts in our scripts array
if (!self.scripts.length > 0) {
return self.onComplete(); // we dont, we are done
if (!(self.scripts.length > 0)) {
code = self.stream.toString();
return self.onComplete(code); // we dont, we are done
}

@@ -195,0 +196,0 @@

{
"name": "crushit",
"version": "0.1.1",
"version": "0.1.2",
"description": "Script minifier for production",
"main": "lib/main.js",
"main": "index.js",
"bin": {

@@ -13,3 +13,3 @@ "crushit": "main.js"

"scripts": {
"test": "mocha test/main.js"
"test": "mocha test/main.js test/app.js"
},

@@ -28,3 +28,3 @@ "repository": {

"cheerio": "~0.10.3",
"uglify-js": "latest",
"uglify-js": "~2.2.3",
"commander": "~1.1.1"

@@ -31,0 +31,0 @@ },

# CrushIt
CrushIt is a commandline tool for compiling all javascript scripts from a web page and minifying them into a single file. I wrote CrushIt to make it easy to optimize my code for use in production.
CrushIt is a commandline tool for compiling, concatenating, and minifying scripts from a web page. I wrote CrushIt to make it easy to optimize my code for use in production.

@@ -33,6 +33,14 @@ [![Build Status](https://travis-ci.org/qawemlilo/crushit.png)](https://travis-ci.org/qawemlilo/crushit)

```
# Optimizing apple.com scripts
# Compiling scripts from my website
crushit http://www.rflab.co.za
```
# You can also include CrushIt in your node programs
```
var crushit = require('crushit');
crushit.optimize();
```
# To Do

@@ -39,0 +47,0 @@

@@ -123,5 +123,5 @@

describe('#loadWebPage', function() {
it('should load all scripts from http://www.rflab.co.za', function(done) {
it('should load all scripts from http://www.apple.com', function(done) {
crushIt.init({
website: 'http://www.rflab.co.za',
website: 'http://www.apple.com',
directory: '/',

@@ -128,0 +128,0 @@ parserOptions: {

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