mirror of
https://github.com/plankanban/planka.git
synced 2025-07-22 06:39:44 +02:00
parent
ad7fb51cfa
commit
2ee1166747
1557 changed files with 76832 additions and 47042 deletions
|
@ -1,3 +1,8 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const { rimraf } = require('rimraf');
|
||||
|
||||
|
@ -13,25 +18,31 @@ module.exports = {
|
|||
invalidFile: {},
|
||||
},
|
||||
|
||||
// TODO: add better validation
|
||||
async fn(inputs) {
|
||||
const content = await fs.promises.readFile(inputs.file.fd);
|
||||
const trelloBoard = JSON.parse(content);
|
||||
|
||||
let trelloBoard;
|
||||
try {
|
||||
trelloBoard = JSON.parse(content);
|
||||
} catch (error) {
|
||||
await rimraf(inputs.file.fd);
|
||||
throw 'invalidFile';
|
||||
}
|
||||
|
||||
if (
|
||||
!trelloBoard ||
|
||||
!_.isArray(trelloBoard.labels) ||
|
||||
!_.isArray(trelloBoard.lists) ||
|
||||
!_.isArray(trelloBoard.cards) ||
|
||||
!_.isArray(trelloBoard.checklists) ||
|
||||
!_.isArray(trelloBoard.actions)
|
||||
) {
|
||||
await rimraf(inputs.file.fd);
|
||||
throw 'invalidFile';
|
||||
}
|
||||
|
||||
try {
|
||||
await rimraf(inputs.file.fd);
|
||||
} catch (error) {
|
||||
console.warn(error.stack); // eslint-disable-line no-console
|
||||
}
|
||||
await rimraf(inputs.file.fd);
|
||||
|
||||
return trelloBoard;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue