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

ckeditor / ckeditor5-package-generator / 1156

pending completion
1156

push

travis-ci-com

web-flow
Merge pull request #147 from ckeditor/i/144

Feature: Add `augmentation.ts` to the TypeScript package generator. Closes ckeditor/ckeditor5-package-generator#144.

117 of 117 branches covered (100.0%)

Branch coverage included in aggregate %.

420 of 420 relevant lines covered (100.0%)

8.92 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-2023, CKSource Holding sp. z o.o. All rights reserved.
3
 * For licensing, see LICENSE.md.
4
 */
5

6
'use strict';
7

8
const { prompt } = require( 'inquirer' );
6✔
9

10
const PROGRAMMING_LANGUAGES = [
6✔
11
        { value: 'js', displayName: 'JavaScript' },
12
        { value: 'ts', displayName: 'TypeScript (experimental)' }
13
];
14

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

27
                if ( langShorthands.includes( lang ) ) {
2✔
28
                        return lang;
1✔
29
                }
30

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

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

42
        // Full name to shorthand: "JavaScript" => "js"
43
        return PROGRAMMING_LANGUAGES.find( p => p.displayName === programmingLanguage ).value;
6✔
44
};
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