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

ckeditor / ckeditor5-package-generator / #765

pending completion
#765

travis-ci

117 of 117 branches covered (100.0%)

Branch coverage included in aggregate %.

416 of 416 relevant lines covered (100.0%)

8.97 hits per line

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

100.0
/packages/ckeditor5-package-generator/lib/utils/install-dependencies.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 { tools } from '@ckeditor/ckeditor5-dev-utils';
7
import chalk from 'chalk';
8
import { spawn } from 'node:child_process';
8✔
9

8✔
10
/**
8✔
11
 * @param {String} directoryPath
12
 * @param {'npm'|'yarn'|'pnpm'} packageManager
13
 * @param {Boolean} verbose
14
 * @param {Boolean} dev
15
 * @returns {Promise}
16
 */
17
export default async function installDependencies( directoryPath, packageManager, verbose, dev ) {
18
        const installSpinner = tools.createSpinner( 'Installing dependencies... ' + chalk.gray.italic( 'It takes a while.' ), {
19
                isDisabled: verbose
8✔
20
        } );
7✔
21

22
        installSpinner.start();
23

24
        await installPackages( directoryPath, packageManager, verbose, dev );
7✔
25

26
        installSpinner.finish();
7✔
27
}
28

6✔
29
/**
30
 * @param {String} directoryPath
31
 * @param {'npm'|'yarn'|'pnpm'} packageManager
32
 * @param {Boolean} verbose
33
 * @param {Boolean} dev
34
 * @returns {Promise}
35
 */
36
function installPackages( directoryPath, packageManager, verbose, dev ) {
37
        return new Promise( ( resolve, reject ) => {
38
                const spawnOptions = {
39
                        encoding: 'utf8',
7✔
40
                        shell: true,
7✔
41
                        cwd: directoryPath,
42
                        stderr: 'inherit'
43
                };
44

45
                let installTask;
46

47
                if ( verbose ) {
48
                        spawnOptions.stdio = 'inherit';
49
                }
7✔
50

3✔
51
                if ( packageManager === 'npm' ) {
52
                        const npmArguments = [
53
                                'install'
7✔
54
                        ];
3✔
55

56
                        // Flag required for npm 8 to install linked packages' dependencies
57
                        if ( dev ) {
58
                                npmArguments.push( '--install-links' );
59
                        }
3✔
60

1✔
61
                        installTask = spawn( 'npm', npmArguments, spawnOptions );
62
                } else if ( packageManager === 'yarn' ) {
63
                        installTask = spawn( 'yarnpkg', [], spawnOptions );
3✔
64
                } else if ( packageManager === 'pnpm' ) {
65
                        installTask = spawn( 'pnpm', [ 'install' ], spawnOptions );
4✔
66
                } else {
67
                        throw new Error( 'Unhandled package manager ' + packageManager );
68
                }
7✔
69

7✔
70
                installTask.on( 'close', exitCode => {
1✔
71
                        if ( exitCode ) {
72
                                return reject( new Error( 'Installing dependencies finished with an error.' ) );
73
                        }
6✔
74

75
                        return resolve();
76
                } );
77
        } );
78
}
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