Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if ( urlInfo ) {
repositoryPath = path.join( workspaceAbsolutePath, urlInfo.name );
if ( tools.isDirectory( repositoryPath ) ) {
log.info( `Directory ${ repositoryPath } already exists.` );
} else {
log.info( `Cloning ${ urlInfo.name } into ${ repositoryPath }...` );
git.cloneRepository( urlInfo, workspaceAbsolutePath );
}
// Checkout to specified branch if one is provided.
if ( urlInfo.branch ) {
log.info( `Checking ${ urlInfo.name } to ${ urlInfo.branch }...` );
git.checkout( repositoryPath, urlInfo.branch );
}
// Run `npm install` in new repository.
log.info( `Running "npm install" in ${ urlInfo.name }...` );
tools.npmInstall( repositoryPath );
const linkPath = path.join( ckeditor5Path, 'node_modules', urlInfo.name );
log.info( `Linking ${ linkPath } to ${ repositoryPath }...` );
tools.linkDirectories( repositoryPath, linkPath );
log.info( `Adding ${ urlInfo.name } dependency to CKEditor5 package.json...` );
tools.updateJSONFile( path.join( ckeditor5Path, 'package.json' ), ( json ) => {
json.dependencies = json.dependencies || {};
json.dependencies[ urlInfo.name ] = dependency;
json.dependencies = tools.sortObject( json.dependencies );
if ( dependencies ) {
const directories = workspace.getDirectories( workspaceAbsolutePath );
for ( let dependency in dependencies ) {
const repositoryURL = dependencies[ dependency ];
const urlInfo = git.parseRepositoryUrl( repositoryURL );
const repositoryAbsolutePath = path.join( workspaceAbsolutePath, dependency );
// Check if repository's directory already exists.
if ( directories.indexOf( urlInfo.name ) > -1 ) {
log.info( `Fetching branches from ${ urlInfo.name }...` );
git.fetchAll( repositoryAbsolutePath );
log.info( `Checking out ${ urlInfo.name } to ${ urlInfo.branch }...` );
git.checkout( repositoryAbsolutePath, urlInfo.branch );
log.info( `Pulling changes to ${ urlInfo.name }...` );
git.pull( repositoryAbsolutePath, urlInfo.branch );
if ( runNpmUpdate ) {
log.info( `Running "npm update" in ${ urlInfo.name }...` );
tools.npmUpdate( repositoryAbsolutePath );
}
try {
log.info( `Linking ${ repositoryURL }...` );
tools.linkDirectories( repositoryAbsolutePath, path.join( ckeditor5Path, 'node_modules', dependency ) );
} catch ( error ) {
log.error( error );
}
} else {