@villedemontreal/general-utils 5.17.0 → 5.17.2
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/src/apiError.js +24 -1
- package/dist/src/apiError.js.map +1 -1
- package/dist/src/apiErrorBuilder.js +24 -1
- package/dist/src/apiErrorBuilder.js.map +1 -1
- package/dist/src/collectionUtils.d.ts +1 -1
- package/dist/src/collectionUtils.js +24 -1
- package/dist/src/collectionUtils.js.map +1 -1
- package/dist/src/collectionUtils.test.js +24 -1
- package/dist/src/collectionUtils.test.js.map +1 -1
- package/dist/src/config/constants.js +24 -1
- package/dist/src/config/constants.js.map +1 -1
- package/dist/src/dateUtils.d.ts +4 -4
- package/dist/src/dateUtils.js +17 -14
- package/dist/src/dateUtils.js.map +1 -1
- package/dist/src/dateUtils.test.js +11 -8
- package/dist/src/dateUtils.test.js.map +1 -1
- package/dist/src/logLevel.js +1 -1
- package/dist/src/logLevel.js.map +1 -1
- package/dist/src/orderBy.js +25 -2
- package/dist/src/orderBy.js.map +1 -1
- package/dist/src/stringUtils.js +24 -1
- package/dist/src/stringUtils.js.map +1 -1
- package/dist/src/timer.js +24 -1
- package/dist/src/timer.js.map +1 -1
- package/dist/src/utils.d.ts +2 -2
- package/dist/src/utils.js +55 -41
- package/dist/src/utils.js.map +1 -1
- package/dist/src/utils.test.js +24 -1
- package/dist/src/utils.test.js.map +1 -1
- package/package.json +14 -15
- package/src/dateUtils.test.ts +2 -2
- package/src/dateUtils.ts +2 -2
- package/src/utils.ts +15 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@villedemontreal/general-utils",
|
|
3
|
-
"version": "5.17.
|
|
3
|
+
"version": "5.17.2",
|
|
4
4
|
"description": "General utilities library",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -38,36 +38,35 @@
|
|
|
38
38
|
"author": "Ville de Montréal",
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@types/app-root-path": "1.2.
|
|
42
|
-
"@types/lodash": "4.14.
|
|
43
|
-
"@types/luxon": "
|
|
44
|
-
"@types/rimraf": "3.0.2",
|
|
41
|
+
"@types/app-root-path": "1.2.6",
|
|
42
|
+
"@types/lodash": "4.14.199",
|
|
43
|
+
"@types/luxon": "3.3.2",
|
|
45
44
|
"app-root-path": "3.1.0",
|
|
46
45
|
"get-port": "5.1.1",
|
|
47
|
-
"globby": "13.
|
|
46
|
+
"globby": "13.2.2",
|
|
48
47
|
"http-status-codes": "2.2.0",
|
|
49
48
|
"lodash": "4.17.21",
|
|
50
|
-
"luxon": "
|
|
49
|
+
"luxon": "3.4.3",
|
|
51
50
|
"moment": "2.29.4",
|
|
52
|
-
"rimraf": "
|
|
51
|
+
"rimraf": "5.0.5",
|
|
53
52
|
"tsconfig-extends": "1.0.1"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
|
-
"@types/chai": "4.3.
|
|
55
|
+
"@types/chai": "4.3.6",
|
|
57
56
|
"@types/fs-extra": "9.0.13",
|
|
58
57
|
"@types/mocha": "9.1.1",
|
|
59
58
|
"@types/node": "16.x",
|
|
60
|
-
"@types/sinon": "10.0.
|
|
61
|
-
"@types/uuid": "
|
|
59
|
+
"@types/sinon": "10.0.18",
|
|
60
|
+
"@types/uuid": "9.0.4",
|
|
62
61
|
"@villedemontreal/lint-config": "1.7.7",
|
|
63
|
-
"chai": "4.3.
|
|
62
|
+
"chai": "4.3.10",
|
|
64
63
|
"fs-extra": "10.1.0",
|
|
65
64
|
"mocha": "9.2.2",
|
|
66
65
|
"mocha-jenkins-reporter": "0.4.7",
|
|
67
|
-
"sinon": "
|
|
66
|
+
"sinon": "16.0.0",
|
|
68
67
|
"source-map-support": "0.5.21",
|
|
69
68
|
"ts-node": "^10.9.1",
|
|
70
|
-
"typescript": "
|
|
71
|
-
"uuid": "
|
|
69
|
+
"typescript": "5.2.2",
|
|
70
|
+
"uuid": "9.0.1"
|
|
72
71
|
}
|
|
73
72
|
}
|
package/src/dateUtils.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assert } from 'chai';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import moment from 'moment';
|
|
4
4
|
import { getValueDescription, getValueDescriptionWithType, utils } from '.';
|
|
5
5
|
import { getCartesianProduct } from './collectionUtils';
|
|
6
6
|
import {
|
package/src/dateUtils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _ from 'lodash';
|
|
2
2
|
import { DateTime, Zone } from 'luxon';
|
|
3
|
-
import
|
|
3
|
+
import moment from 'moment';
|
|
4
4
|
// tslint:disable-next-line:no-duplicate-imports
|
|
5
5
|
import { Moment } from 'moment';
|
|
6
6
|
import { getValueDescription, utils } from '.';
|
package/src/utils.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { spawn, StdioOptions } from 'child_process';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import getPort from 'get-port';
|
|
4
|
+
import _ from 'lodash';
|
|
5
5
|
import * as pathUtils from 'path';
|
|
6
|
-
import
|
|
6
|
+
import { rimraf } from 'rimraf';
|
|
7
7
|
import * as tsconfig from 'tsconfig-extends';
|
|
8
8
|
import { constants } from './config/constants';
|
|
9
9
|
|
|
@@ -202,16 +202,12 @@ export class Utils {
|
|
|
202
202
|
*
|
|
203
203
|
* You can't delete a root file using this function.
|
|
204
204
|
*/
|
|
205
|
-
public
|
|
205
|
+
public deleteFile(filePath: string) {
|
|
206
206
|
if (!this.isSafeToDelete(filePath)) {
|
|
207
207
|
throw new Error("Unsafe file to delete. A file to delete can't be at the root.");
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
return
|
|
211
|
-
rimraf(filePath, () => {
|
|
212
|
-
resolve();
|
|
213
|
-
});
|
|
214
|
-
});
|
|
210
|
+
return rimraf(filePath);
|
|
215
211
|
}
|
|
216
212
|
|
|
217
213
|
/**
|
|
@@ -225,24 +221,16 @@ export class Utils {
|
|
|
225
221
|
throw new Error("Unsafe dir to delete. A dir to delete can't be at the root.");
|
|
226
222
|
}
|
|
227
223
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
await this.clearDir(dirPath);
|
|
239
|
-
await new Promise<void>((resolve2, reject2) => {
|
|
240
|
-
rimraf(dirPath, () => {
|
|
241
|
-
resolve2();
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
});
|
|
224
|
+
try {
|
|
225
|
+
return rimraf(dirPath);
|
|
226
|
+
} catch (err) {
|
|
227
|
+
// ==========================================
|
|
228
|
+
// Try recursively as rimraf may sometimes
|
|
229
|
+
// fail in infrequent situations...
|
|
230
|
+
// ==========================================
|
|
231
|
+
await this.clearDir(dirPath);
|
|
232
|
+
return rimraf(dirPath);
|
|
233
|
+
}
|
|
246
234
|
}
|
|
247
235
|
|
|
248
236
|
/**
|