Ajout de la carte de Vieux-Marché.

This commit is contained in:
David Soulayrol
2023-11-11 23:25:38 +01:00
parent 7966d5d7ba
commit 4d66ff6934
7 changed files with 114 additions and 4 deletions

View File

@@ -0,0 +1,47 @@
const debug = require('debug')('metalsmith-copy')
const fs = require('fs')
const mode = require('stat-mode')
const path = require('path')
module.exports = plugin
function plugin (options) {
options = Object.assign({ destination: '.' }, options)
return function (files, metalsmith, done) {
const dest = options.destination
const items = options.files.length
const promises = []
const addTask = function (promise) {
promises.push(promise)
if (items === promises.length) {
debug('Waiting for ' + items + 'copy operations.')
Promise.all(promises)
.then((data) => {
done()
})
.catch((err) => {
done(err)
})
}
}
options.files.forEach((filename) => {
addTask(new Promise(function (resolve, reject) {
fs.stat(filename, function (err, stats) {
if (err) return reject(err)
fs.readFile(filename, function (err, buffer) {
if (err) return reject(err)
const file = {
contents: buffer,
mode: mode(stats).toOctal()
}
files[path.join(dest, path.basename(filename))] = file
resolve({})
})
})
}))
})
}
}