broccoli-kitchen-sink-helpers
Advanced tools
Comparing version 0.2.1 to 0.2.2
# master | ||
# 0.2.2 | ||
* Make `hashTree` match after `copyRecursivelySync`, by disregarding the | ||
name of the root directory and not including directory times | ||
# 0.2.1 | ||
@@ -4,0 +9,0 @@ |
33
index.js
@@ -22,4 +22,11 @@ var fs = require('fs') | ||
function keysForTree (fullPath, _stack, _followSymlink) { | ||
function keysForTree (fullPath, options) { | ||
options = options || {} | ||
var _stack = options._stack | ||
var _followSymlink = options._followSymlink | ||
var relativePath = options.relativePath || '.' | ||
var stats | ||
var statKeys | ||
try { | ||
@@ -37,2 +44,7 @@ if (_followSymlink) { | ||
var childKeys = [] | ||
if (stats) { | ||
statKeys = ['stats', stats.mode] | ||
} else { | ||
statKeys = ['stat failed'] | ||
} | ||
if (stats && stats.isDirectory()) { | ||
@@ -55,3 +67,8 @@ var fileIdentity = stats.dev + '\x00' + stats.ino | ||
for (var i = 0; i < entries.length; i++) { | ||
childKeys = childKeys.concat(keysForTree(path.join(fullPath, entries[i]), _stack)) | ||
var keys = keysForTree(path.join(fullPath, entries[i]), { | ||
_stack: _stack, | ||
relativePath: path.join(relativePath, entries[i]) | ||
}) | ||
childKeys = childKeys.concat(keys) | ||
} | ||
@@ -68,7 +85,13 @@ } | ||
} | ||
childKeys = keysForTree(fullPath, _stack, true) // follow symlink | ||
childKeys = keysForTree(fullPath, {_stack: _stack, relativePath: relativePath, _followSymlink: true}) // follow symlink | ||
statKeys.push(stats.mtime.getTime()) | ||
statKeys.push(stats.size) | ||
} else if (stats && stats.isFile()) { | ||
statKeys.push(stats.mtime.getTime()) | ||
statKeys.push(stats.size) | ||
} | ||
// Perhaps we should not use basename to infer the file name | ||
return ['path', path.basename(fullPath)] | ||
.concat(stats ? ['stats', stats.mode, stats.size, stats.mtime.getTime()] : ['stat failed']) | ||
return ['path', relativePath] | ||
.concat(statKeys) | ||
.concat(childKeys) | ||
@@ -75,0 +98,0 @@ } |
{ | ||
"name": "broccoli-kitchen-sink-helpers", | ||
"description": "Collection of helpers that need to be extracted into separate packages", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "Jo Liss <joliss42@gmail.com>", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
10716
205