Skip to content

Commit

Permalink
Fixing output file path messages (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
munozemilio committed Oct 29, 2019
1 parent a67721b commit 8ca578e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/chatdown/src/commands/chatdown/convert.ts
Expand Up @@ -153,7 +153,7 @@ export default class ChatdownConvert extends Command {
let validatedPath = utils.validatePath(writeFile, '', force)
await fs.ensureFile(writeFile)
await fs.writeJson(validatedPath, activities, {spaces: 2})
return writeFile
return validatedPath
}
const output = JSON.stringify(activities, null, 2)
await new Promise(done => process.stdout.write(output, 'utf-8', () => done()))
Expand Down
4 changes: 2 additions & 2 deletions packages/config/src/commands/config/index.ts
Expand Up @@ -4,7 +4,7 @@
*/

import {Command, flags} from '@oclif/command'

const path = require('path')
export default class ConfigIndex extends Command {
static description = 'Configure various settings within the cli.'

Expand All @@ -13,7 +13,7 @@ export default class ConfigIndex extends Command {
}

async run() {
this.log(`\nConfig file location: ' ${this.config.configDir}/config.json \n `)
this.log(`\nConfig file location: ' ${path.join(this.config.configDir, 'config.json')} \n `)
this._help()
}
}
6 changes: 3 additions & 3 deletions packages/lu/src/commands/luis/convert.ts
Expand Up @@ -81,13 +81,13 @@ export default class LuisConvert extends Command {

private async writeOutput(convertedObject: any, flags: any, isLu: boolean) {
let filePath = await file.generateNewFilePath(flags.out, flags.in, isLu)
const validatedPath = utils.validatePath(filePath, '', flags.force)
// write out the final file
try {
const validatedPath = utils.validatePath(filePath, '', flags.force)
await fs.writeFile(validatedPath, convertedObject, 'utf-8')
} catch (err) {
throw new CLIError('Unable to write file - ' + filePath + ' Error: ' + err.message)
throw new CLIError('Unable to write file - ' + validatedPath + ' Error: ' + err.message)
}
this.log('Successfully wrote LUIS model to ' + filePath)
this.log('Successfully wrote LUIS model to ' + validatedPath)
}
}
12 changes: 6 additions & 6 deletions packages/lu/src/commands/qnamaker/convert.ts
Expand Up @@ -78,21 +78,21 @@ export default class QnamakerConvert extends Command {

private async writeOutput(convertedObject: any, flags: any, isQnA: boolean) {
let filePath = await file.generateNewFilePath(flags.out, flags.in, isQnA, '', fileExtEnum.QnAFile)
const validatedPath = utils.validatePath(filePath, '', flags.force)
try {
if (isQnA) {
let validatedPath = utils.validatePath(filePath, '', flags.force)
await fs.writeFile(validatedPath, JSON.stringify(convertedObject.finalQnAJSON, null, 2), 'utf-8')
if (convertedObject.finalQnAAlterations) {
let filePathAlterations = await file.generateNewFilePath(flags.out, flags.in, isQnA, 'alterations_', fileExtEnum.QnAFile)
let validatedPath = utils.validatePath(filePathAlterations, '', flags.force)
await fs.writeFile(validatedPath, JSON.stringify(convertedObject.finalQnAAlterations, null, 2), 'utf-8')
const validatedPathAlter = utils.validatePath(filePathAlterations, '', flags.force)
await fs.writeFile(validatedPathAlter, JSON.stringify(convertedObject.finalQnAAlterations, null, 2), 'utf-8')
}
} else {
await fs.writeFile(filePath, convertedObject, 'utf-8')
await fs.writeFile(validatedPath, convertedObject, 'utf-8')
}
} catch (err) {
throw new CLIError('Unable to write file - ' + filePath + ' Error: ' + err.message)
throw new CLIError('Unable to write file - ' + validatedPath + ' Error: ' + err.message)
}
this.log('Successfully wrote QnA model to ' + filePath)
this.log('Successfully wrote QnA model to ' + validatedPath)
}
}

0 comments on commit 8ca578e

Please sign in to comment.