fable 3.0.52 → 3.0.53
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/dist/fable.compatible.js +4 -4
- package/dist/fable.compatible.min.js +1 -1
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +2 -2
- package/dist/fable.min.js +1 -1
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/services/Fable-Service-FilePersistence.js +9 -6
- package/test/FilePersistence_tests.js +47 -0
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ class FableServiceFilePersistence extends libFableServiceBase
|
|
|
21
21
|
this.currentOutputFolder = `/tmp`;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
joinPath(pPathArray)
|
|
24
|
+
joinPath(...pPathArray)
|
|
25
25
|
{
|
|
26
26
|
return libPath.resolve(...pPathArray);
|
|
27
27
|
}
|
|
@@ -55,6 +55,11 @@ class FableServiceFilePersistence extends libFableServiceBase
|
|
|
55
55
|
return libFS.unlinkSync(pFileName);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
deleteFolderSync(pFileName)
|
|
59
|
+
{
|
|
60
|
+
return libFS.rmdirSync(pFileName);
|
|
61
|
+
}
|
|
62
|
+
|
|
58
63
|
writeFileSyncFromObject(pFileName, pObject)
|
|
59
64
|
{
|
|
60
65
|
return this.writeFileSync(pFileName, JSON.stringify(pObject, null, 4));
|
|
@@ -99,8 +104,7 @@ class FableServiceFilePersistence extends libFableServiceBase
|
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
// Folder management
|
|
102
|
-
|
|
103
|
-
makeFolderRecursive (pParameters, fCallback)
|
|
107
|
+
makeFolderRecursive(pParameters, fCallback)
|
|
104
108
|
{
|
|
105
109
|
let tmpParameters = pParameters;
|
|
106
110
|
|
|
@@ -160,7 +164,7 @@ class FableServiceFilePersistence extends libFableServiceBase
|
|
|
160
164
|
|
|
161
165
|
// Check if the path exists (and is a folder)
|
|
162
166
|
libFS.open(tmpParameters.CurrentPath + libPath.sep + tmpParameters.ActualPathParts[tmpParameters.CurrentPathIndex], 'r',
|
|
163
|
-
|
|
167
|
+
(pError, pFileDescriptor)=>
|
|
164
168
|
{
|
|
165
169
|
if (pFileDescriptor)
|
|
166
170
|
{
|
|
@@ -189,8 +193,7 @@ class FableServiceFilePersistence extends libFableServiceBase
|
|
|
189
193
|
{
|
|
190
194
|
return this.makeFolderRecursive(tmpParameters, fCallback);
|
|
191
195
|
}
|
|
192
|
-
}
|
|
193
|
-
);
|
|
196
|
+
});
|
|
194
197
|
}
|
|
195
198
|
}
|
|
196
199
|
|
|
@@ -69,6 +69,53 @@ suite
|
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
71
|
test
|
|
72
|
+
(
|
|
73
|
+
'Join a path.',
|
|
74
|
+
function(fTestComplete)
|
|
75
|
+
{
|
|
76
|
+
let testFable = new libFable();
|
|
77
|
+
let tmpFilePersistence = testFable.serviceManager.instantiateServiceProvider('FilePersistence');
|
|
78
|
+
|
|
79
|
+
Expect(tmpFilePersistence.joinPath('/tmp/tests/../othertests/names/'))
|
|
80
|
+
.to.equal('/tmp/othertests/names');
|
|
81
|
+
|
|
82
|
+
return fTestComplete();
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
test
|
|
86
|
+
(
|
|
87
|
+
'Create a recursive folder.',
|
|
88
|
+
function(fTestComplete)
|
|
89
|
+
{
|
|
90
|
+
let testFable = new libFable();
|
|
91
|
+
let tmpFilePersistence = testFable.serviceManager.instantiateServiceProvider('FilePersistence');
|
|
92
|
+
let tmpDataGeneration = testFable.serviceManager.instantiateServiceProvider('DataGeneration');
|
|
93
|
+
|
|
94
|
+
let tmpFolderExtras = [];
|
|
95
|
+
|
|
96
|
+
for (let i = 0; i < 3; i++)
|
|
97
|
+
{
|
|
98
|
+
tmpFolderExtras.push(tmpDataGeneration.randomName());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let tmpFullPathName = `/tmp/${tmpFolderExtras.join('/')}`;
|
|
102
|
+
testFable.log.info(`Creating test folder recursively: [${tmpFullPathName}]`);
|
|
103
|
+
|
|
104
|
+
tmpFilePersistence.makeFolderRecursive(tmpFullPathName, (pError)=>
|
|
105
|
+
{
|
|
106
|
+
// Now clean up the folder
|
|
107
|
+
for (let i = 0; i < 3; i++)
|
|
108
|
+
{
|
|
109
|
+
tmpFullPathName = `/tmp/${tmpFolderExtras.join('/')}`;
|
|
110
|
+
testFable.log.info(`Deleting test folder recursively: [${tmpFullPathName}]`);
|
|
111
|
+
tmpFilePersistence.deleteFolderSync(tmpFullPathName);
|
|
112
|
+
tmpFolderExtras.pop();
|
|
113
|
+
}
|
|
114
|
+
return fTestComplete();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
test
|
|
72
119
|
(
|
|
73
120
|
'Create, write, read and then delete a file.',
|
|
74
121
|
function(fTestComplete)
|