@engine9-io/input-tools 1.6.1 → 1.6.4
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/file/S3.js +5 -2
- package/index.js +2 -0
- package/package.json +1 -1
package/file/S3.js
CHANGED
@@ -187,7 +187,7 @@ Worker.prototype.write.metadata = {
|
|
187
187
|
},
|
188
188
|
};
|
189
189
|
|
190
|
-
Worker.prototype.list = async function ({ directory }) {
|
190
|
+
Worker.prototype.list = async function ({ directory, raw }) {
|
191
191
|
if (!directory) throw new Error('directory is required');
|
192
192
|
let dir = directory;
|
193
193
|
while (dir.slice(-1) === '/') dir = dir.slice(0, -1);
|
@@ -200,14 +200,17 @@ Worker.prototype.list = async function ({ directory }) {
|
|
200
200
|
});
|
201
201
|
|
202
202
|
const { Contents: files, CommonPrefixes } = await s3Client.send(command);
|
203
|
+
if (raw) return files;
|
203
204
|
// debug('Prefixes:', { CommonPrefixes });
|
204
205
|
const output = [].concat((CommonPrefixes || []).map((f) => ({
|
205
206
|
name: f.Prefix.slice(Prefix.length + 1, -1),
|
206
207
|
type: 'directory',
|
207
208
|
})))
|
208
|
-
.concat((files || []).map(({ Key }) => ({
|
209
|
+
.concat((files || []).map(({ Key, Size, LastModified }) => ({
|
209
210
|
name: Key.slice(Prefix.length + 1),
|
210
211
|
type: 'file',
|
212
|
+
size: Size,
|
213
|
+
modifiedAt: new Date(LastModified).toISOString(),
|
211
214
|
})));
|
212
215
|
|
213
216
|
return output;
|
package/index.js
CHANGED
@@ -49,6 +49,8 @@ handlebars.registerHelper('json', (d) => JSON.stringify(d));
|
|
49
49
|
|
50
50
|
handlebars.registerHelper('percent', (a, b) => `${((100 * a) / b).toFixed(2)}%`);
|
51
51
|
|
52
|
+
handlebars.registerHelper('or', (a, b, c) => a || b || c);
|
53
|
+
|
52
54
|
function isValidDate(d) {
|
53
55
|
// we WANT to use isNaN, not the Number.isNaN -- we're checking the date type
|
54
56
|
// eslint-disable-next-line no-restricted-globals
|