Fix create-user command and make it actually save a file

Earlier, it used to print out the stuff to the screen, which you'd
then have to copy to a file manually - tedious!

By the way, the other fixes were typos and omissions while changing
Seance from a simple file to an object.
This commit is contained in:
Badri Sunderarajan 2020-05-08 15:39:44 +05:30
parent 8117d24b4c
commit 6496768956
2 changed files with 7 additions and 3 deletions

6
cli.js
View File

@ -159,7 +159,11 @@ program.command('create-user <username> <email>')
console.log(`Error: ${err.error}`)
return
})
console.log(await jsonOut);
const userSlug = JSON.parse(jsonOut).data.users[0].slug
const outFile = `user-${userSlug}.json`
await fs.promises.writeFile(outFile, jsonOut, 'utf-8')
console.log(`Saved to ${outFile}`);
});
program.command('webdav-test <file>')

View File

@ -417,7 +417,7 @@ class Seance {
const mediumUrl = `https://medium.com/@${mediumUsername}/?format=json`;
const json = await fetchMediumJSON(mediumUrl);
const json = await this.fetchMediumJSON(mediumUrl);
if (!json.success) {
this.emit('error', {
@ -447,7 +447,7 @@ class Seance {
loglevel: 'debug'
})
let imagePath = MEDIUM_IMG_CDN + '256/256/' + imageId
let imagePath = this.MEDIUM_IMG_CDN + '256/256/' + imageId
let filetype = imageId.split('.')[imageId.split('.').length - 1]
let fileName = `${mediumUsername}.${filetype}`
let filePath = path.join(process.env.PWD, fileName)