Skip to content

Commit

Permalink
fix(gatsby-plugin-subfont): escape file paths (#12905)
Browse files Browse the repository at this point in the history
fixes #12702
  • Loading branch information
violy authored and pieh committed Mar 28, 2019
1 parent ff102c9 commit 2133288
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/gatsby-plugin-subfont/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.0.0",
"shell-escape": "^0.2.0",
"subfont": "^3.6.1"
},
"devDependencies": {
Expand Down
18 changes: 12 additions & 6 deletions packages/gatsby-plugin-subfont/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
const path = require(`path`)
const { execSync } = require(`child_process`)
const shellescape = require(`shell-escape`)

exports.onPostBuild = ({ store }) => {
const root = path.join(store.getState().program.directory, `public`)
// TODO make this configurable
const urlPaths = [`/`]
const filePaths = urlPaths.reduce(
(accumulator, currentPath) =>
`${accumulator} ${path.join(root, currentPath, `index.html`)}`,
``
const baseArgs = [
`node_modules/.bin/subfont`,
`-i`,
`--no-recursive`,
`--inline-css`,
`--root`,
`file://${root}`,
]
const args = baseArgs.concat(
urlPaths.map(currentPath => path.join(root, currentPath, `index.html`))
)

const command = `node_modules/.bin/subfont -i --no-recursive --inline-css --root file://${root}${filePaths}`
const command = shellescape(args)
execSync(command)
}

0 comments on commit 2133288

Please sign in to comment.