Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚑 Fix reverse build #242

Open
wants to merge 2 commits into
base: v3/latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jovo-cli-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"jovo-config": "^0.1.0",
"listr": "^0.14.2",
"lodash": "^4.17.15",
"strip-ansi": "^7.0.1",
"tv4": "^1.3.0",
"uuid": "^3.2.1"
},
Expand Down
11 changes: 10 additions & 1 deletion jovo-cli-core/src/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as chalk from 'chalk';
import * as fs from 'fs';
import { sep as pathSep } from 'path';
import * as chalk from 'chalk';
import stripAnsi from 'strip-ansi';

export function log(msg: undefined | string | object) {
let data = '';
Expand Down Expand Up @@ -54,3 +55,11 @@ export function printStage(stage: undefined | string) {
export function printWarning(message: string) {
return chalk.yellow.bold(`[WARN] ${message}`);
}

/**
* Strips ANSI escape codes from the provided string.
* @param output - String potentially containing ANSI escape codes to be stripped.
*/
export function getRawString(output: string): string {
return stripAnsi(output);
}
4 changes: 2 additions & 2 deletions jovo-cli-platforms/jovo-cli-platform-alexa/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExecOptions, exec } from 'child_process';
import { JovoCliError } from 'jovo-cli-core';
import { JovoCliError, Utils } from 'jovo-cli-core';
import _get from 'lodash.get';

export * from './Interfaces';
Expand All @@ -25,7 +25,7 @@ export function getAskErrorV2(method: string, stderr: string): JovoCliError {

const errorIndex: number = stderr.indexOf(splitter);
if (errorIndex > -1) {
const errorString: string = stderr.substring(errorIndex + splitter.length);
const errorString: string = Utils.getRawString(stderr.substring(errorIndex + splitter.length));
const parsedError = JSON.parse(errorString);
const payload = _get(parsedError, 'detail.response', parsedError);
const message: string = payload.message;
Expand Down
11 changes: 6 additions & 5 deletions jovo-cli-platforms/jovo-cli-platform-google/src/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,16 @@ export class JovoCliPlatformGoogle extends JovoCliPlatform {
const supportedLanguages = this.getLocales();

for (let locale of supportedLanguages) {
// transform en-us to en-US
if (locale.length === 5) {
locale = locale.substr(0, 2) + '-' + locale.substr(3).toUpperCase();
}

reverseLocales.push({
title: locale,
task: async () => {
const jovoModel = await this.reverse(locale);

// transform en-us to en-US
if (locale.length === 5) {
locale = locale.substr(0, 2) + '-' + locale.substr(3).toUpperCase();
}

return project.saveModel(jovoModel, locale);
},
});
Expand Down