Comparing version 0.0.2 to 0.1.0
@@ -9,5 +9,7 @@ #!/usr/bin/env node | ||
var options = require('nomnom') | ||
var parser = require('nomnom') | ||
.script('bolivar') | ||
.help('Get independant from external css, js and images') | ||
.help('Get independant from external css, js and images'); | ||
parser.command('start') | ||
.option('root', { | ||
@@ -28,28 +30,59 @@ abbr: 'r', | ||
}) | ||
.parse() | ||
.option('parent', { | ||
abbr: 'p', | ||
default: '', | ||
help: 'Parent directory of the assets' | ||
}) | ||
.option('child', { | ||
abbr: 'c', | ||
default: '', | ||
help: 'Child directory of the assets' | ||
}) | ||
.option('css', { | ||
default: 'css', | ||
help: 'The directory name for .css files' | ||
}) | ||
.option('js', { | ||
default: 'js', | ||
help: 'The directory name for .js files' | ||
}) | ||
.option('img', { | ||
default: 'img', | ||
help: 'The directory name for image files' | ||
}) | ||
.help('Start the replacing') | ||
.callback(function(options) { | ||
start(options); | ||
}) | ||
; | ||
// To be included in CLI | ||
options.paths = false; | ||
parser.parse(); | ||
function start(options) { | ||
options.paths = { | ||
css: path.join(options.parent, options.css, options.child), | ||
js: path.join(options.parent, options.js, options.child), | ||
img: path.join(options.parent, options.img, options.child) | ||
}; | ||
var bolivar = new Bolivar(options); | ||
var bolivar = new Bolivar(options); | ||
if(!options.silent) { | ||
console.log('Root ' + options.root); | ||
if(!options.silent) { | ||
console.log('Root ' + options.root); | ||
bolivar.on('file', function(data) { | ||
console.log('File: ' + data.name); | ||
}); | ||
bolivar.on('file', function(data) { | ||
console.log('File: ' + data.name); | ||
}); | ||
bolivar.on('url', function(data) { | ||
console.log('* ' + data.url); | ||
}); | ||
} | ||
bolivar.on('url', function(data) { | ||
console.log('* ' + data.url); | ||
}); | ||
} | ||
if(!options.force && !fs.existsSync(path.join(options.root, '.git'))) { | ||
console.error('No .git found in root. Use -f if you are sure what you are doing.'); | ||
process.exit(); | ||
if(!options.force && !fs.existsSync(path.join(options.root, '.git'))) { | ||
console.error('No .git found in root. Use -f if you are sure what you are doing.'); | ||
process.exit(); | ||
} | ||
bolivar.start(); | ||
} | ||
bolivar.start(); |
12
index.js
@@ -50,3 +50,5 @@ var fs = require('fs'); | ||
} | ||
}); | ||
}); | ||
self.finder.on('end', self.emit.bind(self, 'end')); | ||
}; | ||
@@ -85,5 +87,5 @@ | ||
var savePath = this.options.paths[type]; | ||
var intFile = fs.createWriteStream(path.join(savePath, filename)); | ||
var intFile = fs.createWriteStream(path.join(this.options.root, savePath, filename)); | ||
http.get(url, function(extFile) { | ||
extFile.pipe(intFile) | ||
extFile.pipe(intFile); | ||
}); | ||
@@ -93,5 +95,5 @@ return path.join('/', savePath, filename); | ||
return url; | ||
} | ||
} | ||
}; | ||
module.exports = Bolivar; | ||
module.exports = Bolivar; |
{ | ||
"name": "bolivar", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Get independant from external css, js and images", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha test/test.js" | ||
}, | ||
@@ -24,3 +24,7 @@ "repository": { | ||
"nomnom": "~1.6.2" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.18.2", | ||
"mkdirp": "~0.5.0" | ||
} | ||
} |
@@ -5,12 +5,16 @@ # Bolivar | ||
Bolivar is a CLI for removing external CSS, JS and image dependencies from your projects, moving them into `css`, `js` and `img` folders. It's convenient if you used a lot of CDNs and external images and now want to work offline on your HTML. | ||
Bolivar is a CLI for removing external CSS, JS and image dependencies from your | ||
projects, moving them into `css`, `js` and `img` folders. It's convenient if you | ||
used a lot of CDNs and external images and now want to work offline on your HTML. | ||
Just install it with `npm install -g bolivar` and use `bolivar` in your projects root. | ||
Just install it with `npm install -g bolivar` and use `bolivar start` in your | ||
projects root. | ||
Make sure the project is GIT version controlled in case Bolivar screws something up. Bolivar will skip the `.git` and `node_modules` directories. | ||
Make sure the project is GIT version controlled in case Bolivar screws something | ||
up. Bolivar will skip the `.git` and `node_modules` directories. | ||
## Command Line usage | ||
``` | ||
$ bolivar -h | ||
Usage: bolivar [options] | ||
$ bolivar start -h | ||
Usage: bolivar start [options] | ||
@@ -21,4 +25,9 @@ Options: | ||
-f, --force Run bolivar without aborting on warnings | ||
-p, --parent Parent directory of the assets [] | ||
-c, --child Child directory of the assets [] | ||
--css The directory name for .css files [css] | ||
--js The directory name for .js files [js] | ||
--img The directory name for image files [img] | ||
Get independant from external css, js and images | ||
Start the replacing | ||
``` | ||
@@ -28,3 +37,4 @@ | ||
## Script usage | ||
You can also use bolivar via require. It will not `console.log` messages but emit `file` and `url` events. | ||
You can also use bolivar via require. It will not `console.log` messages but emit | ||
`file` and `url` events as well as an `end` event. | ||
```javascript | ||
@@ -60,2 +70,2 @@ var bolivar = require('bolivar'); | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
THE SOFTWARE. |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
12385
10
208
2
68
2
3