Make it possible to require and use monolith as a node module

pull/7/head
vflyson 7 years ago
parent c07f5c72ec
commit 6d0a6f6416

@ -1,5 +1,7 @@
#!/usr/bin/env nodejs #!/usr/bin/env nodejs
'use strict'
var compactor = require('../compactor.js'); var compactor = require('../compactor.js');
var options = require('../options.js'); var options = require('../options.js');
@ -29,7 +31,7 @@ if (process.argv.length > 2) {
} }
if (target) { if (target) {
compactor(target, function(error, result) { compactor(target, options, function(error, result) {
console.log(result) console.log(result)
}) })
} else { } else {

@ -1,5 +1,3 @@
#!/usr/bin/env node
'use strict' 'use strict'
var path = require('path') var path = require('path')
@ -26,7 +24,11 @@ var modules = [
require('./modules/anchors.js').parser, require('./modules/anchors.js').parser,
] ]
function monolith (targetDocumentPath, callback) { function monolith (targetDocumentPath, _options, callback) {
// In case monolith got included as a library
for (var k in _options)
options[k] = _options[k]
// Determine the absolute initial document path // Determine the absolute initial document path
var absBasePath = isURL(targetDocumentPath) var absBasePath = isURL(targetDocumentPath)
? absoluteURLPath(targetDocumentPath) ? absoluteURLPath(targetDocumentPath)

@ -2,7 +2,7 @@
"name": "monolith", "name": "monolith",
"version": "0.4.5", "version": "0.4.5",
"description": "Save HTML pages with ease", "description": "Save HTML pages with ease",
"main": "index.js", "main": "compactor.js",
"dependencies": { "dependencies": {
"sync-request": "^3.0.1", "sync-request": "^3.0.1",
"jsdom": "^9.9.1" "jsdom": "^9.9.1"
@ -14,7 +14,11 @@
"test": "bin/index.js https://github.com > github.html" "test": "bin/index.js https://github.com > github.html"
}, },
"keywords": [ "keywords": [
"html5", "hoarding",
"save-the-internet",
"procrastination",
"its-mine",
"no-more-404",
"monolith", "monolith",
"one-for-all", "one-for-all",
"all-for-one" "all-for-one"

Loading…
Cancel
Save