Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const uploadTree = (client, datasetId) => tree => {
return client
.mutate({
mutation: files.updateFiles,
variables: { datasetId, files: tree },
})
.catch(err => {
// Since the error response content type does not match the request
// we need some special error handling any requests with Upload scalars
if (
err.hasOwnProperty('networkError') &&
err.networkError &&
err.networkError.hasOwnProperty('result')
) {
for (const message of err.networkError.result.errors) {
// eslint-disable-next-line no-console
console.error(inspect(message))
}
process.exit(1)
} else {
export const updateFiles = client => (datasetId, fileList) => {
const tree = treeFromList(fileList)
// Upload dataset_description.json first
tree.files = files.sortFiles(tree.files)
return client.mutate({
mutation: files.updateFiles,
variables: { datasetId, files: tree },
errorPolicy: 'all',
})
}
updateFiles(datasetId, fileTree, options) {
let mutation = files.updateFiles
return new Promise((resolve, reject) => {
client.mutate({
mutation: mutation,
variables: {
datasetId: bids.decodeId(datasetId),
files: fileTree
}
})
.then(data => {
console.log('response from updateFiles:', data)
resolve(data)
})
.catch(err => {
console.log(err)
reject(err)