Explorar el Código

Updated dev-install task to not store local paths in packge.json.

Szymon Kupś hace 10 años
padre
commit
258102e889
Se han modificado 2 ficheros con 8 adiciones y 3 borrados
  1. 6 1
      dev/tasks/utils/dev-install.js
  2. 2 2
      dev/tests/dev-install.js

+ 6 - 1
dev/tasks/utils/dev-install.js

@@ -29,6 +29,7 @@ const path = require( 'path' );
 module.exports = ( ckeditor5Path, workspaceRoot, name, writeln ) => {
 	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 	let repositoryPath;
+	let dependency;
 	let urlInfo;
 
 	// First check if name is local path to repository.
@@ -42,12 +43,15 @@ module.exports = ( ckeditor5Path, workspaceRoot, name, writeln ) => {
 			urlInfo = {
 				name: packageName
 			};
+
+			dependency = repositoryPath;
 		}
 	}
 
 	// Check if name is repository URL.
 	if ( !urlInfo ) {
 		urlInfo = git.parseRepositoryUrl( name );
+		dependency = name;
 	}
 
 	// Check if name is NPM package.
@@ -57,6 +61,7 @@ module.exports = ( ckeditor5Path, workspaceRoot, name, writeln ) => {
 
 		if ( url ) {
 			urlInfo = git.parseRepositoryUrl( url );
+			dependency  = url;
 		}
 	}
 
@@ -83,7 +88,7 @@ module.exports = ( ckeditor5Path, workspaceRoot, name, writeln ) => {
 		writeln( `Adding ${ urlInfo.name } dependency to CKEditor5 package.json... ` );
 		tools.updateJSONFile( path.join( ckeditor5Path, 'package.json' ), ( json ) => {
 			json.dependencies = json.dependencies || {};
-			json.dependencies[ urlInfo.name ] = repositoryPath;
+			json.dependencies[ urlInfo.name ] = dependency;
 
 			return json;
 		} );

+ 2 - 2
dev/tests/dev-install.js

@@ -75,7 +75,7 @@ describe( 'dev-install', () => {
 		const updateFn = spies.updateJSON.firstCall.args[ 1 ];
 		const json = updateFn( {} );
 		expect( json.dependencies ).to.be.a( 'object' );
-		expect( json.dependencies[ urlInfo.name ] ).to.equal( repositoryPath );
+		expect( json.dependencies[ urlInfo.name ] ).to.equal( repositoryUrl );
 
 		sinon.assert.calledOnce( spies.npmInstall );
 		sinon.assert.calledWithExactly( spies.npmInstall, ckeditor5Path );
@@ -115,7 +115,7 @@ describe( 'dev-install', () => {
 		const updateFn = spies.updateJSON.firstCall.args[ 1 ];
 		const json = updateFn( {} );
 		expect( json.dependencies ).to.be.a( 'object' );
-		expect( json.dependencies[ urlInfo.name ] ).to.equal( repositoryPath );
+		expect( json.dependencies[ urlInfo.name ] ).to.equal( repositoryUrl );
 
 		sinon.assert.calledOnce( spies.npmInstall );
 		sinon.assert.calledWithExactly( spies.npmInstall, ckeditor5Path );