• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ckeditor / ckeditor5-package-generator / #725

pending completion
#725

travis-ci

117 of 117 branches covered (100.0%)

Branch coverage included in aggregate %.

420 of 420 relevant lines covered (100.0%)

10.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/packages/ckeditor5-package-generator/lib/utils/choose-programming-language.js
1
/**
2
 * @license Copyright (c) 2020-2025, CKSource Holding sp. z o.o. All rights reserved.
3
 * For licensing, see LICENSE.md.
4
 */
5

6
import inquirer from 'inquirer';
7

8
const PROGRAMMING_LANGUAGES = [
6✔
9
        { value: 'ts', displayName: 'TypeScript' },
10
        { value: 'js', displayName: 'JavaScript' }
6✔
11
];
12

13
/**
14
 * Chooses programming language. If --lang option us used, and it has valid value, that is returned.
15
 * Otherwise, ask user to choose from available programming languages.
16
 *
17
 * @param {Logger} logger
18
 * @param {String} lang
19
 * @returns {Promise<String>}
20
 */
21
export default async function chooseProgrammingLanguage( logger, lang ) {
22
        if ( lang ) {
23
                const langShorthands = PROGRAMMING_LANGUAGES.map( ( { value } ) => value );
6✔
24

5✔
25
                if ( langShorthands.includes( lang ) ) {
4✔
26
                        return lang;
27
                }
2✔
28

1✔
29
                logger.error( `--lang option has to be one of: ${ langShorthands.join( ', ' ) }. Falling back to manual choice.` );
30
        }
31

1✔
32
        const { programmingLanguage } = await inquirer.prompt( [ {
33
                prefix: '📍',
34
                name: 'programmingLanguage',
4✔
35
                message: 'Choose your programming language:',
36
                type: 'list',
37
                choices: PROGRAMMING_LANGUAGES.map( ( { displayName } ) => displayName )
38
        } ] );
39

8✔
40
        // Full name to shorthand: "JavaScript" => "js"
41
        return PROGRAMMING_LANGUAGES.find( p => p.displayName === programmingLanguage ).value;
42
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc