@reldens/server-utils 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/file-handler.js +4 -0
- package/package.json +1 -1
package/lib/file-handler.js
CHANGED
|
@@ -90,6 +90,7 @@ class FileHandler
|
|
|
90
90
|
let origin = Array.isArray(from) ? this.joinPaths(...from) : from;
|
|
91
91
|
let dest = Array.isArray(to) ? this.joinPaths(...to) : to;
|
|
92
92
|
if(!this.exists(origin)){
|
|
93
|
+
this.error = {message: 'Failed to copy file, origin does not exists.', from, to, origin, dest};
|
|
93
94
|
return false;
|
|
94
95
|
}
|
|
95
96
|
try {
|
|
@@ -142,6 +143,7 @@ class FileHandler
|
|
|
142
143
|
fs.rmSync(crudTestPath);
|
|
143
144
|
return true;
|
|
144
145
|
} catch (error) {
|
|
146
|
+
this.error = {message: 'Failed to check permissions.', error, systemPath};
|
|
145
147
|
return false;
|
|
146
148
|
}
|
|
147
149
|
}
|
|
@@ -150,6 +152,7 @@ class FileHandler
|
|
|
150
152
|
{
|
|
151
153
|
let fileContents = this.fetchFileContents(filePath);
|
|
152
154
|
if(!fileContents){
|
|
155
|
+
this.error = {message: 'Failed to fetch file contents.', filePath};
|
|
153
156
|
return false;
|
|
154
157
|
}
|
|
155
158
|
let importedJson = JSON.parse(fileContents);
|
|
@@ -163,6 +166,7 @@ class FileHandler
|
|
|
163
166
|
fetchFileContents(filePath)
|
|
164
167
|
{
|
|
165
168
|
if(!this.isFile(filePath)){
|
|
169
|
+
this.error = {message: 'File check failed to fetch file contents.', filePath};
|
|
166
170
|
return false;
|
|
167
171
|
}
|
|
168
172
|
let fileContent = this.readFile(filePath);
|