From 1e7365963e4e2346293812c780aa11300fef3224 Mon Sep 17 00:00:00 2001 From: Alexander Matsievsky Date: Tue, 25 Jul 2017 10:53:20 +0300 Subject: [PATCH] feat(xod-cli): allow orgmembers to publish lib versions --- packages/xod-cli/src/xodc-publish.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/xod-cli/src/xodc-publish.js b/packages/xod-cli/src/xodc-publish.js index 50b4ea0b..674cf723 100644 --- a/packages/xod-cli/src/xodc-publish.js +++ b/packages/xod-cli/src/xodc-publish.js @@ -64,12 +64,15 @@ export default async function publish(swaggerUrl, orgname$, projectDir) { throw swagger.error(err2); }); }); - await Library.putOrgLib({ lib: {}, libname, orgname }).catch((err) => { - if (err.status === 403) { - throw new Error(`user "${username}" can't access ${ - toStringWithoutTag(libUri)}.`); - } - throw swagger.error(err); + await Library.getOrgLib({ libname, orgname }).catch((err) => { + if (err.status !== 404) throw swagger.error(err); + return Library.putOrgLib({ lib: {}, libname, orgname }).catch((err2) => { + if (err2.status === 403) { + throw new Error(`user "${username}" can't access ${ + toStringWithoutTag(libUri)}.`); + } + throw swagger.error(err2); + }); }); await Version.postLibVersion({ libname, orgname, version }).catch((err) => { if (err.status === 409) {