Fixed #1 (Source file is transformed).

This commit is contained in:
David Soulayrol 2023-08-28 21:49:09 +02:00
parent fec615f7d9
commit 99f77dfe0a
3 changed files with 26 additions and 1 deletions

View file

@ -167,7 +167,10 @@ function plugin (options) {
return new Promise((resolve, reject) => {
let dir = path.dirname(file),
destination = path.basename(file, path.extname(file)) + '.' + pluginOptions.device,
data = files[file],
data = {
contents: Buffer.from(files[file].contents),
mode: files[file].mode
}
input = data.contents
if (dir !== '.')

1
test/fixtures/source/src/foo.ms vendored Normal file
View file

@ -0,0 +1 @@
foo

View file

@ -130,4 +130,25 @@ describe('metalsmith-groff', function () {
'Preprocessors are missing: ' + Object.values(preprocessors))
})
})
it('should keep the source file if requested to do so', function (done) {
const metalsmith = Metalsmith('test/fixtures/source'),
logger = debug('metalsmith-groff:test:source')
metalsmith
.use(groff({
exe: 'test/groff_mock',
source: true
}))
.use((files, metalsmith) => {
assert.equal(Object.keys(files).length, 2, 'Expected two files on output!')
assert.equal(files['foo.ms'].contents.toString('utf8'), 'foo',
'Source file was modified!')
})
.process((err) => {
if (err)
throw err
done()
})
})
})