Debug output tidying

This commit is contained in:
Aaron Suen 2020-03-28 07:21:46 -04:00
parent ff59fd7df1
commit e3a93ceef4
3 changed files with 16 additions and 13 deletions

View File

@ -24,11 +24,12 @@ module.exports = async () => {
const $ = await cdblib.fetch(uri);
const fields = cdblib.getfields($);
const tags = {};
let tags = {};
meta.tags.split(',')
.filter(x => /\S/.test(x))
.map(x => x.trim())
.forEach(x => tags[cdblib.findopt($, 'select#tags option', x)] = true);
tags = Object.keys(tags);
delete meta.tags;
'type license media_license'.split(' ')
@ -46,20 +47,22 @@ module.exports = async () => {
meta.repo = config.fromgit;
Object.assign(fields, meta);
let body = Object.keys(fields)
.sort()
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(fields[k]));
Object.keys(tags)
.map(k => Number(k))
.sort()
.forEach(k => body.push('tags=' + k));
if(config.dryrun) {
console.log('dry run; not saving details');
console.log(body);
fields.tags = tags;
console.log(require('util')
.inspect(fields));
return;
}
let body = Object.keys(fields)
.sort()
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(fields[k]));
tags.forEach(k => body.push('tags=' + k));
body = body.join('&');
console.log('applying package detail changes...');
await cdblib.fetch(uri, 'post', body.join('&'));
await cdblib.fetch(uri, 'post', body);
console.log('package details updated');
};

View File

@ -33,7 +33,7 @@ async function makerelease() {
fields.title = config.version;
if(config.dryrun) {
console.log('dry run; not submitting');
console.log(JSON.stringify(fields));
console.log(require('util').inspect(fields));
return;
}
console.log('submitting new release...');

View File

@ -11,7 +11,7 @@ const cdbedit = require('./cdbedit');
const readFile = util.promisify(fs.readFile);
process.on('unhandledRejection', e => {
console.log(e);
console.warn(e);
process.exit(1);
});
@ -22,7 +22,7 @@ process.on('unhandledRejection', e => {
if(conf)
config.set('fromfile', JSON.parse(conf.toString()));
} catch (e) {
console.log(e.message || e);
console.warn(e.message || e);
}
if(config.fromgit)