Skip to content

Commit

Permalink
Use second optional positional attribute (target) as generated-file-name
Browse files Browse the repository at this point in the history
  • Loading branch information
andboss committed May 10, 2020
1 parent 41a16b4 commit f8b5cde
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ module.exports.save = function (diagramUrl, doc, target, format, vfs) {
} else {
dirPath = path.join(baseDir, imagesDir)
}
const diagramName = `diag-${rusha.createHash().update(diagramUrl).digest('hex')}.${format}`
let diagramName
if (target) {
diagramName = `${target}.${format}`
} else {
diagramName = `diag-${rusha.createHash().update(diagramUrl).digest('hex')}.${format}`
}
let exists
if (typeof vfs === 'undefined' || typeof vfs.exists !== 'function') {
exists = require('./node-fs').exists
Expand Down
42 changes: 38 additions & 4 deletions test/test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f8b5cde

Please sign in to comment.