1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-08-01 19:45:26 +02:00

Add an import feature for import Trello board as JSON to Planka

This commit is contained in:
FaustinM 2021-03-25 17:55:36 +01:00
parent a3d1a8a09a
commit a729e11636
24 changed files with 925 additions and 10872 deletions

View file

@ -0,0 +1,33 @@
const util = require('util');
const stream = require('stream');
const streamToArray = require('stream-to-array');
module.exports = {
sync: true,
fn(inputs, exits) {
const receiver = stream.Writable({
objectMode: true,
});
let firstFileHandled = false;
// eslint-disable-next-line no-underscore-dangle
receiver._write = async (file, receiverEncoding, done) => {
if (firstFileHandled) {
file.pipe(new stream.Writable());
return done();
}
firstFileHandled = true;
const buffer = await streamToArray(file).then((parts) =>
Buffer.concat(parts.map((part) => (util.isBuffer(part) ? part : Buffer.from(part)))),
);
// eslint-disable-next-line no-param-reassign
file.extra = buffer.toString('UTF-8');
return done();
};
return exits.success(receiver);
},
};