Skip to content

Commit

Permalink
Chore: Move camelCaseDash to the package where it is consumed (#21736)
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo authored Apr 20, 2020
1 parent 56ae122 commit dd9f454
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 49 deletions.
20 changes: 20 additions & 0 deletions packages/dependency-extraction-webpack-plugin/test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,30 @@
* Internal dependencies
*/
const {
camelCaseDash,
defaultRequestToExternal,
defaultRequestToHandle,
} = require( '../util' );

describe( 'camelCaseDash', () => {
test( 'does not change a single word', () => {
expect( camelCaseDash( 'blocks' ) ).toBe( 'blocks' );
expect( camelCaseDash( 'dom' ) ).toBe( 'dom' );
} );

test( 'does not capitalize letters following numbers', () => {
expect( camelCaseDash( 'a11y' ) ).toBe( 'a11y' );
expect( camelCaseDash( 'i18n' ) ).toBe( 'i18n' );
} );

test( 'converts dashes into camel case', () => {
expect( camelCaseDash( 'api-fetch' ) ).toBe( 'apiFetch' );
expect( camelCaseDash( 'list-reusable-blocks' ) ).toBe(
'listReusableBlocks'
);
} );
} );

describe( 'defaultRequestToExternal', () => {
test( 'Returns undefined on unrecognized request', () => {
expect( defaultRequestToExternal( 'unknown-request' ) ).toBeUndefined();
Expand Down
3 changes: 1 addition & 2 deletions packages/dependency-extraction-webpack-plugin/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ function defaultRequestToHandle( request ) {
* converting to uppercase, where Lodash will also capitalize letters
* following numbers.
*
* Temporarily duplicated from @wordpress/scripts/utils.
*
* @param {string} string Input dash-delimited string.
*
* @return {string} Camel-cased string.
Expand All @@ -92,6 +90,7 @@ function camelCaseDash( string ) {
}

module.exports = {
camelCaseDash,
defaultRequestToExternal,
defaultRequestToHandle,
};
2 changes: 0 additions & 2 deletions packages/scripts/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ const {
} = require( './env' );
const { fromProjectRoot, fromConfigRoot, hasProjectFile } = require( './file' );
const { hasPackageProp } = require( './package' );
const { camelCaseDash } = require( './string' );

module.exports = {
buildWordPress,
camelCaseDash,
fromProjectRoot,
fromConfigRoot,
getArgFromCLI,
Expand Down
19 changes: 0 additions & 19 deletions packages/scripts/utils/string.js

This file was deleted.

25 changes: 0 additions & 25 deletions packages/scripts/utils/test/string.js

This file was deleted.

4 changes: 3 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const { basename, sep } = require( 'path' );
const CustomTemplatedPathPlugin = require( '@wordpress/custom-templated-path-webpack-plugin' );
const LibraryExportDefaultPlugin = require( '@wordpress/library-export-default-webpack-plugin' );
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
const { camelCaseDash } = require( '@wordpress/scripts/utils' );
const {
camelCaseDash,
} = require( '@wordpress/dependency-extraction-webpack-plugin/util' );

/**
* Internal dependencies
Expand Down

0 comments on commit dd9f454

Please sign in to comment.