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

ckeditor / ckeditor5-package-generator / 1155

pending completion
1155

push

travis-ci-com

web-flow
Merge pull request #148 from ckeditor/i/136

Other (tools): Update `terser-webpack-plugin` to enable optional chaining syntax. Closes #136.

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/install-dependencies.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 { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
8✔
9
const chalk = require( 'chalk' );
8✔
10
const { spawn } = require( 'child_process' );
8✔
11

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

24
        installSpinner.start();
7✔
25

26
        await installPackages( directoryPath, packageManager, verbose, dev );
7✔
27

28
        installSpinner.finish();
6✔
29
};
30

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

47
                let installTask;
48

49
                if ( verbose ) {
7✔
50
                        spawnOptions.stdio = 'inherit';
3✔
51
                }
52

53
                if ( packageManager === 'npm' ) {
7✔
54
                        const npmArguments = [
3✔
55
                                'install',
56
                                '--prefix',
57
                                directoryPath
58
                        ];
59

60
                        // Flag required for npm 8 to install linked packages' dependencies
61
                        if ( dev ) {
3✔
62
                                npmArguments.push( '--install-links' );
1✔
63
                        }
64

65
                        installTask = spawn( 'npm', npmArguments, spawnOptions );
3✔
66
                } else {
67
                        const yarnArguments = [
4✔
68
                                '--cwd',
69
                                directoryPath
70
                        ];
71

72
                        installTask = spawn( 'yarnpkg', yarnArguments, spawnOptions );
4✔
73
                }
74

75
                installTask.on( 'close', exitCode => {
7✔
76
                        if ( exitCode ) {
7✔
77
                                return reject( new Error( 'Installing dependencies finished with an error.' ) );
1✔
78
                        }
79

80
                        return resolve();
6✔
81
                } );
82
        } );
83
}
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