@cntwg/xml-lib-js 0.0.17 → 0.0.18
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/CHANGELOG.md +6 -0
- package/lib/xmldoc-lib.js +15 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/xmldoc-lib.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.048-20220908]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -832,12 +832,18 @@ class TXmlContentContainer {
|
|
|
832
832
|
return new Promise((resolve, reject) => {
|
|
833
833
|
let data = {
|
|
834
834
|
isSucceed: false,
|
|
835
|
-
source: typeof source === 'string' ? source.trim : '',
|
|
835
|
+
source: typeof source === 'string' ? source.trim() : '',
|
|
836
836
|
content: '',
|
|
837
837
|
isERR: false,
|
|
838
838
|
errEvent: '',
|
|
839
839
|
};
|
|
840
|
-
if (data.source
|
|
840
|
+
if (data.source === '') {
|
|
841
|
+
data.isERR = true;
|
|
842
|
+
data.errEvent = (
|
|
843
|
+
typeof source === 'string' ? 'EMPTY_SRCLINK' : 'NO_SRCLINK'
|
|
844
|
+
);
|
|
845
|
+
resolve(data);
|
|
846
|
+
} else {
|
|
841
847
|
data.content = this.saveToXMLString();
|
|
842
848
|
fse.writeFile(data.source, data.content, 'utf8').then(result => {
|
|
843
849
|
data.isSucceed = true;
|
|
@@ -848,16 +854,11 @@ class TXmlContentContainer {
|
|
|
848
854
|
console.log('CHECK: TXmlContentContainer.saveToFile() => Error => '+err.code);
|
|
849
855
|
reject(err);
|
|
850
856
|
});
|
|
851
|
-
} else {
|
|
852
|
-
data.isERR = true;
|
|
853
|
-
data.errEvent = 'EMPTY_SRCLINK';
|
|
854
|
-
resolve(data);
|
|
855
857
|
};
|
|
856
858
|
});
|
|
857
859
|
}
|
|
858
860
|
|
|
859
861
|
saveToFileSync(source){
|
|
860
|
-
//console.log('CHECK: TXmlContentContainer.saveToFileSync() => was called...');
|
|
861
862
|
let data = {
|
|
862
863
|
isSucceed: false,
|
|
863
864
|
source: typeof source === 'string' ? source.trim() : '',
|
|
@@ -865,7 +866,12 @@ class TXmlContentContainer {
|
|
|
865
866
|
isERR: false,
|
|
866
867
|
errEvent: '',
|
|
867
868
|
};
|
|
868
|
-
if (data.source
|
|
869
|
+
if (data.source === '') {
|
|
870
|
+
data.isERR = true;
|
|
871
|
+
data.errEvent = (
|
|
872
|
+
typeof source === 'string' ? 'EMPTY_SRCLINK' : 'NO_SRCLINK'
|
|
873
|
+
);
|
|
874
|
+
} else {
|
|
869
875
|
try {
|
|
870
876
|
data.content = this.saveToXMLString();
|
|
871
877
|
fs.writeFileSync(data.source, data.content, 'utf8');
|
|
@@ -874,11 +880,7 @@ class TXmlContentContainer {
|
|
|
874
880
|
console.log('CHECK: TXmlContentContainer.saveToFileSync() => Error => '+err.code);
|
|
875
881
|
throw err;
|
|
876
882
|
};
|
|
877
|
-
} else {
|
|
878
|
-
data.isERR = true;
|
|
879
|
-
data.errEvent = 'EMPTY_SRCLINK';
|
|
880
883
|
};
|
|
881
|
-
//console.log('CHECK: TXmlContentContainer.saveToFileSync() => was left...');
|
|
882
884
|
return data;
|
|
883
885
|
}
|
|
884
886
|
|