Skip to content

Commit

Permalink
Use path.join
Browse files Browse the repository at this point in the history
  • Loading branch information
dojineko committed Apr 9, 2018
1 parent 5ee7711 commit 8ea2be6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/gatsby-plugin-manifest/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require(`fs`)
const path = require(`path`)
const Promise = require(`bluebird`)
const sharp = require(`sharp`)
const defaultIcons = require(`./common.js`).defaultIcons
Expand All @@ -8,7 +9,7 @@ sharp.simd(true)
function generateIcons(icons, srcIcon) {
return Promise.map(icons, icon => {
const size = parseInt(icon.sizes.substring(0, icon.sizes.lastIndexOf(`x`)))
const imgPath = `./public/` + icon.src
const imgPath = path.join(`public`, icon.src)

return sharp(srcIcon)
.resize(size)
Expand All @@ -33,14 +34,14 @@ exports.onPostBuild = (args, pluginOptions) =>
}

// Determine destination path for icons.
const iconPath = `./public/` + manifest.icons[0].src.substring(0, manifest.icons[0].src.lastIndexOf(`/`))
const iconPath = path.join(`public`, manifest.icons[0].src.substring(0, manifest.icons[0].src.lastIndexOf(`/`)))

//create destination directory if it doesn't exist
if (!fs.existsSync(iconPath)){
fs.mkdirSync(iconPath)
}

fs.writeFileSync(`./public/manifest.json`, JSON.stringify(manifest))
fs.writeFileSync(path.join(`public`, `manifest.json`), JSON.stringify(manifest))

// Only auto-generate icons if a src icon is defined.
if (icon !== undefined) {
Expand Down

0 comments on commit 8ea2be6

Please sign in to comment.