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

Implemented option to install dependencies using npm #38

Merged
merged 6 commits into from
Sep 29, 2021
Merged
Changes from 1 commit
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
34 changes: 21 additions & 13 deletions packages/create-ckeditor5-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ async function init( packageName, options ) {

// (4.)
console.log( '📍 Install dependencies...' );
installPackages( directoryPath );
installPackages( directoryPath, options.useNpm );

// (5.)
console.log( '📍 Initializing Git repository...' );
Expand Down Expand Up @@ -170,23 +170,31 @@ function copyTemplate( templateFile, packagePath, data ) {
/**
* @param {String} directoryPath
*/
function installPackages( directoryPath /* Support for NPM */ ) {
const yarnArguments = [
'--cwd',
directoryPath
];

// if ( verbose ) {
// yarnArguments.push( '--verbose' );
// }

spawnSync( 'yarnpkg', yarnArguments, {
function installPackages( directoryPath, useNpm ) {
const spawnOptions = {
encoding: 'utf8',
shell: true,
cwd: directoryPath,
stdio: 'inherit',
stderr: 'inherit'
} );
};

if ( useNpm ) {
const npmArguments = [
'install',
'--prefix',
directoryPath
];

spawnSync( 'npm', npmArguments, spawnOptions );
} else {
const yarnArguments = [
'--cwd',
directoryPath
];

spawnSync( 'yarnpkg', yarnArguments, spawnOptions );
}
}

/**
Expand Down