Skip to content

Commit

Permalink
Made sure to not do the work copying if already done
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiedo committed Jul 19, 2017
1 parent a81d972 commit 188426f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions packages/gatsby-transformer-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
"license": "MIT",
"dependencies": {
"bluebird": "^3.5.0",
"image-size": "^0.6.0",
"ncp": "^2.0.0",
"util.promisify": "^1.0.0"
"fs-extra": "^4.0.0",
"image-size": "^0.6.0"
},
"devDependencies": {
"babel-cli": "^6.24.1"
Expand Down
11 changes: 8 additions & 3 deletions packages/gatsby-transformer-sharp/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ const {

const sharp = require(`sharp`)
const promisify = require('util.promisify');
const ncp = require('ncp');
const ncpAsync = promisify(ncp);
const fsExtra = require('fs-extra');
const sizeOf = require('image-size');
const path = require('path');

Expand Down Expand Up @@ -86,7 +85,13 @@ module.exports = ({ type, pathPrefix, getNodeAndSavePathDependency }) => {
`static/${imageName}`
);

await ncpAsync(details.absolutePath, publicPath);
if (!fsExtra.existsSync(publicPath)) {
fsExtra.copy(details.absolutePath, publicPath, err => {
if (err) {
console.error(`error copying file`, err)
}
})
}

return {
width: dimensions.width,
Expand Down

0 comments on commit 188426f

Please sign in to comment.