Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/abecms/abecms
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Apr 3, 2017
2 parents 66b63c1 + 0080d37 commit 549b648
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -65,6 +65,7 @@
"express-secure-handlebars": "^2.1.0",
"express-session": "^1.13.0",
"extend": "^3.0.0",
"fs-compare": "0.0.4",
"fs-extra": "^2.0.0",
"handlebars": "^4.0.3",
"handlebars-helper-slugify": "^0.3.2",
Expand Down
30 changes: 29 additions & 1 deletion src/cli/cms/templates/assets.js
@@ -1,4 +1,5 @@
import fse from 'fs-extra'
import fsCompare from 'fs-compare'
import dircompare from 'dir-compare'
import mkdirp from 'mkdirp'
import path from 'path'
Expand Down Expand Up @@ -47,7 +48,25 @@ export function copy() {
var basePath = original.replace(publicFolder, '')
var move = path.join(dest, basePath)

if(entry.type2 === 'missing' || entry.state === 'distinct') {
if(move === dest){
fse.readdir(original, function (res, items) {
Array.prototype.forEach.call(items, (item) => {
var lstat = fse.lstatSync(path.join(original, item))
var originalItem = path.join(original, item)
var destItem = path.join(dest, item)
if (!lstat.isDirectory()) {
try {
fsCompare(modifiedTime, originalItem, destItem, function (err, diff) {
if(diff > 0) fse.copySync(originalItem, destItem)
})
} catch (e) {
fse.copySync(originalItem, destItem)
}
}
})
})
}
else if(entry.type2 === 'missing' || entry.state === 'distinct') {
fse.removeSync(move)
fse.copySync(original, move)
}
Expand All @@ -59,6 +78,15 @@ export function copy() {
return publicFolders
}

function modifiedTime(fileName, cb) {
fse.stat(fileName, function (err, stat) {
if (err) {
return cb(err);
}
return cb(null, stat.mtime);
});
}

export function getFolders() {
const templateExtension = '.' + config.files.templates.extension
const assetsExtension = config.files.templates.assets
Expand Down

0 comments on commit 549b648

Please sign in to comment.