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

blake

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blake - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

lib/getReader.js

38

bin/cli.js
#!/usr/bin/env node
var blake = require('../index.js')
, cop = require('cop')
, getReader = require('../lib/getReader.js')
, copy = require('../lib/copy.js')
, join = require('path').join

@@ -12,14 +16,24 @@ ;(function () {

}
blake(arg.shift(), arg.shift(), arg)
.on('error', function (err) {
console.error(err)
})
.on('data', function (item) {
console.log(item.path)
})
.on('end', function () {
console.log('OK')
process.exit()
})
var source = arg.shift()
, target = arg.shift()
function bake () {
getReader(source, arg)
.pipe(cop('path'))
.pipe(blake(source, target))
.pipe(cop(function (filename) { return filename + '\n' }))
.pipe(process.stdout)
}
if (!arg.length) {
copy(join(source, 'resources'), target)
.on('error', function (err) {
console.error(err)
})
.on('end', bake)
} else {
bake()
}
})()

@@ -0,7 +1,13 @@

// generate - generate blake site
var blake = require('blake')
, source = 'blake-site'
, target = '/tmp/blake-site'
, join = require('path').join
, Reader = require('fstream').Reader
, props = { path:join(source, 'data') }
, cop = require('cop')
, copy = require('../lib/copy.js')
blake('blake-site', '/tmp/blake-site')
.on('data', function (item) {
console.log(item)
})
copy(join(source, 'resources'), target)
.on('error', function (err) {

@@ -11,3 +17,7 @@ console.error(err)

.on('end', function () {
console.log('OK')
new Reader(props)
.pipe(cop('path'))
.pipe(blake(source, target))
.pipe(cop(function (filename) { return filename + '\n' }))
.pipe(process.stdout)
})

@@ -5,21 +5,11 @@ // blake - generate site

var resolve = require('path').resolve
, fstream = require('fstream')
, fs = require('fs')
, es = require('event-stream')
, generate = require('./lib/generate.js')
, copy = require('./lib/copy.js')
, popfun = require('popfun')
var generate = require('./lib/generate.js')
, join = require('path').join
function blake () {
var args = Array.prototype.slice.call(arguments)
, source = args.shift()
, target = args.shift()
, callback = popfun(args)
, config = require(resolve(source, 'config.js'))
function blake (source, target) {
var config = require(join(source, 'config.js'))
, paths = require('./lib/paths.js')(source, target, config)
, templates = require('./lib/templates.js')(paths.templates)
, views = config.views
, specific = !!args.length && !!args[0].length
, files = specific ? (Array.isArray(args[0]) ? args[0] : args) : null
var props = {

@@ -30,48 +20,4 @@ templates: templates

}
var writer = generate(props)
if (specific) {
bake()
} else {
copy(paths.resources, target)
.on('error', function (err) {
console.error(err)
})
.on('end', function () {
bake()
})
}
function bake () {
var reader = getReader()
reader.pipe(writer)
writer.on('resume', function () {
reader.resume()
})
writer.on('end', function () {
if (callback) callback()
})
}
function getReader() {
var stream
if (specific) {
var entries = []
files.forEach(function (file) {
entries.push({ path: file })
})
stream = es.readArray(entries)
} else {
stream = fstream.Reader({ path: resolve(source, 'data') })
}
return stream
}
return writer
return generate(props)
}

@@ -7,3 +7,2 @@ // generate - generate and write artifacts

, fs = require('fs')
, resolve = require('path').resolve
, write = require('./write.js')

@@ -33,12 +32,7 @@ , reader = require('./read.js')

stream.add = function (entry) {
if (entry.type === 'Directory') {
entry.on('entry', stream.add)
return true
}
stream.write = function (filename) {
count++
read(entry.path, function (err, item) {
generate(item, function (err) {
read(filename, function (err, item) {
bake(item, function (err) {
if (err) {

@@ -48,3 +42,3 @@ stream.emit('error', err)

stream.emit('data', item)
stream.emit('data', item.path)
count--

@@ -64,5 +58,3 @@

stream.write = stream.add
function generate (item, callback) {
function bake (item, callback) {
if (!item.bake) {

@@ -69,0 +61,0 @@ return callback(new Error(

{
"name": "blake",
"description": "Simple, blog aware infrastructure to generate static sites",
"version": "0.4.1",
"version": "0.5.0",
"homepage": "http://michaelnisi.github.com/blake/",

@@ -6,0 +6,0 @@ "repository": {

@@ -18,45 +18,55 @@ # blake - generate site

Generate all files:
Generate from directory:
var blake = require('blake')
, source = 'blake-site'
, target = '/tmp/blake-site'
, join = require('path').join
, Reader = require('fstream').Reader
, props = { path:join(source, 'data') }
, cop = require('cop')
blake('source', 'target', function (err) {
console.log(err || 'OK')
})
new Reader(props)
.pipe(cop('path'))
.pipe(blake(source, target))
.pipe(cop(function (filename) { return filename + '\n' }))
.pipe(process.stdout)
Generate a specific file:
Copy static resources and generate from directory:
var blake = require('blake')
, source = 'blake-site'
, target = '/tmp/blake-site'
, join = require('path').join
, Reader = require('fstream').Reader
, props = { path:join(source, 'data') }
, cop = require('cop')
, copy = require('../lib/copy.js')
blake('source', 'target', 'source/about.md', function (err) {
console.log(err || 'OK')
})
Generate multiple specific files:
var blake = require('blake')
, source = 'path/to/input'
, target = 'path/to/output'
, home = path.resolve(input, 'home.md')
, archive = path.resolve(input, 'archive.md')
blake(source, target, home, archive , function (err) {
console.log(err || 'OK')
})
It's a Stream—so, you might waive the callback:
var blake = require('blake')
blake('source_directory', 'target_directory')
.on('error', function (err) {
copy(join(source, 'resources'), target)
.on('error', function (err) {
console.error(err)
})
.on('data', function (item) {
console.log(item.path)
})
.on('end', function () {
console.log('OK')
new Reader(props)
.pipe(cop('path'))
.pipe(blake(source, target))
.pipe(cop(function (filename) { return filename + '\n' }))
.pipe(process.stdout)
})
Generate from files:
var blake = require('blake')
, cop = require('cop')
, readArray = require('event-stream').readArray
, filenames = ['first/fil', 'second/file', 'third/file']
, source = 'source_directory'
, target = 'target_directory'
readArray(filenames)
.pipe(blake(source, target))
.pipe(cop(function (filename) { return filename + '\n' }))
.pipe(process.stdout)
## Events

@@ -68,5 +78,5 @@

function (item) { }
function (path) { }
The `data` event emits an item object with these properties: header, body, paths, titles, name, date, templatePath, path, link, dataeString, and template.
The `data` event emits paths of generated artifacts.

@@ -204,2 +214,3 @@ ### Event: 'end'

cd blake/example
npm install
node generate.js

@@ -211,5 +222,6 @@ open /tmp/blake-site/index.html

npm install -g blake
npm install blake jade markdown
git clone git://github.com/michaelnisi/troubled.git
blake troubled /tmp/troubled-site
cd troubled
npm install
blake . /tmp/troubled-site

@@ -216,0 +228,0 @@ ## Deployment

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