lockblocks
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -17,2 +17,3 @@ "use strict"; | ||
var fs_extra_1 = __importDefault(require("fs-extra")); | ||
var dir_compare_1 = require("dir-compare"); | ||
var istextorbinary_1 = require("istextorbinary"); | ||
@@ -151,20 +152,25 @@ var json_format_1 = __importDefault(require("json-format")); | ||
catch (e) { } | ||
if (!destinationIsDir) { | ||
(0, Logging_1.logEvent)(events, Logging_1.LogEventType.action, operation, "Replacing: ".concat(originPath, " -> ").concat(targetPath), { | ||
fileType: 'file', | ||
}); | ||
// Replace file | ||
fs_extra_1.default.ensureFileSync(targetPath); | ||
fs_extra_1.default.copySync(originPath, targetPath, { overwrite: true }); | ||
var same = false; | ||
var targetFileExists = fs_extra_1.default.pathExistsSync(targetPath); | ||
if (targetFileExists) { | ||
var comparisonResults = (0, dir_compare_1.compareSync)(originPath, targetPath, { compareContent: true }); | ||
same = !!(comparisonResults === null || comparisonResults === void 0 ? void 0 : comparisonResults.same); | ||
} | ||
else { | ||
// Replace directory | ||
var originDirExists = fs_extra_1.default.pathExistsSync(originPath); | ||
if (originDirExists) { | ||
// Only replace if there are differences or target doesn't exist | ||
if ((targetFileExists && !same) || !targetFileExists) { | ||
if (!destinationIsDir) { | ||
(0, Logging_1.logEvent)(events, Logging_1.LogEventType.action, operation, "Replacing: ".concat(originPath, " -> ").concat(targetPath), { | ||
fileType: 'file', | ||
}); | ||
// Replace file | ||
fs_extra_1.default.ensureFileSync(targetPath); | ||
fs_extra_1.default.copySync(originPath, targetPath, { overwrite: true }); | ||
} | ||
else { | ||
// Replace directory | ||
(0, Logging_1.logEvent)(events, Logging_1.LogEventType.action, operation, "Replacing: ".concat(originPath, " -> ").concat(targetPath), { | ||
fileType: 'directory', | ||
}); | ||
// Delete target dir or do nothing if doesn't exist | ||
var targetDirExists = fs_extra_1.default.pathExistsSync(targetPath); | ||
if (targetDirExists) { | ||
// Delete target dir first if it exists | ||
if (targetFileExists) { | ||
fs_extra_1.default.rmSync(targetPath, { recursive: true, force: true }); | ||
@@ -175,5 +181,2 @@ } | ||
} | ||
else { | ||
(0, Logging_1.logEvent)(events, Logging_1.LogEventType.warn, operation, "Cannot replace. Origin dir does not exist: ".concat(originPath)); | ||
} | ||
} | ||
@@ -211,3 +214,3 @@ } | ||
if (fs_extra_1.default.readFileSync(currFile).toString() !== fs_extra_1.default.readFileSync(originFilePath).toString()) { | ||
(0, Logging_1.logEvent)(events, Logging_1.LogEventType.action, operation, "Changed detected. Replacing: ".concat(originFilePath, " -> ").concat(currFile), { | ||
(0, Logging_1.logEvent)(events, Logging_1.LogEventType.action, operation, "Replacing: ".concat(originFilePath, " -> ").concat(currFile), { | ||
fileType: 'file', | ||
@@ -214,0 +217,0 @@ }); |
{ | ||
"name": "lockblocks", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"author": "Justin Mahar <contact@justinmahar.com>", | ||
@@ -42,2 +42,3 @@ "description": "Node.js utility for updating projects created from starters.", | ||
"dependencies": { | ||
"dir-compare": "^4.0.0", | ||
"fs-extra": "^10.0.0", | ||
@@ -57,3 +58,2 @@ "istextorbinary": "^6.0.0", | ||
"@typescript-eslint/parser": "^5.6.0", | ||
"dir-compare": "^4.0.0", | ||
"eslint": "^8.4.1", | ||
@@ -60,0 +60,0 @@ "eslint-config-prettier": "^8.3.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1084157
14
1395
8
+ Addeddir-compare@^4.0.0
+ Addeddir-compare@4.2.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedyocto-queue@0.1.0(transitive)