forked from ti-nuage/site
Ajout de la rubrique rencontres.
This commit is contained in:
@@ -10,10 +10,9 @@ function plugin (options) {
|
||||
|
||||
return function (files, metalsmith, done) {
|
||||
const dest = options.destination
|
||||
const items = options.files.length
|
||||
const promises = []
|
||||
|
||||
const addTask = function (promise) {
|
||||
const addTask = function (items, promise) {
|
||||
promises.push(promise)
|
||||
if (items === promises.length) {
|
||||
debug('Waiting for ' + items + 'copy operations.')
|
||||
@@ -27,8 +26,19 @@ function plugin (options) {
|
||||
}
|
||||
}
|
||||
|
||||
options.files.forEach((filename) => {
|
||||
addTask(new Promise(function (resolve, reject) {
|
||||
const iterateFiles = function (options, action) {
|
||||
if (options.files != null) {
|
||||
options.files.forEach((filename) => action(filename, options.files.length))
|
||||
}
|
||||
if (options.generator != null) {
|
||||
options.generator(documents => {
|
||||
documents.forEach((filename) => action(filename, documents.length))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
iterateFiles(options, (filename, items) => {
|
||||
addTask(items, new Promise(function (resolve, reject) {
|
||||
fs.stat(filename, function (err, stats) {
|
||||
if (err) return reject(err)
|
||||
fs.readFile(filename, function (err, buffer) {
|
||||
|
||||
Reference in New Issue
Block a user