Skip to content

Instantly share code, notes, and snippets.

@victorb
Created September 17, 2016 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorb/1414333a84479433aa9b292dae73274c to your computer and use it in GitHub Desktop.
Save victorb/1414333a84479433aa9b292dae73274c to your computer and use it in GitHub Desktop.
function addPipeline (index, addStream, list) {
pull(
zip(
pull.values(list),
pull(
pull.values(list),
paramap(fs.stat.bind(fs), 50)
)
),
pull.map((pair) => ({
path: pair[0],
isDirectory: pair[1].isDirectory()
})),
pull.filter((file) => !file.isDirectory),
pull.map((file) => ({
path: file.path.substring(index, file.path.length),
content: fs.createReadStream(file.path)
})),
addStream,
pull.map((file) => ({
hash: file.hash,
path: file.path
})),
pull.collect((err, added) => {
if (err) {
throw err
}
sortBy(added, 'path')
.reverse()
.map((file) => `added ${file.hash} ${file.path}`)
.forEach((msg) => console.log(msg))
})
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment