Skip to content

Commit

Permalink
Merge pull request #131 from docpress/user-scripts
Browse files Browse the repository at this point in the history
Add Option to add user scripts
  • Loading branch information
rstacruz authored Aug 16, 2016
2 parents 67f64b2 + 0c1a40c commit ea82b91
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ function addJs (files, ms, done) {
files['assets/script.js'] = { contents }
this.scripts.push('assets/script.js?t=' +
hash(files['assets/script.js'].contents))

// Add user's files
let scripts = ms.metadata()

if (Array.isArray(scripts)) {
let userScripts = scripts.map((location) => {
let file = files[location]
if (!file.contents) return
let fileHash = hash(file.contents)
return `${location}?t=${fileHash}`
}).filter((url) => !!url)
this.scripts = this.scripts.concat(userScripts)
}

done()
}

Expand Down

0 comments on commit ea82b91

Please sign in to comment.