Skip to content

Commit

Permalink
Trim dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
fumikito committed Aug 9, 2023
1 parent 20f4b9b commit e700fca
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function grabDeps( file, suffix = '', version = '0.0.0' ) {
const match = assetsContent.match( /'dependencies' => array\(([^)]+)\)/ );
if ( match ) {
match[1].split( ',' ).forEach( ( dep ) => {
deps.push( dep.replaceAll( "'", '' ) );
deps.push( dep.trim().replaceAll( "'", '' ) );
} );
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kunoichi/grab-deps",
"version": "1.3.0",
"version": "1.3.1",
"description": "Grab dependencies from js/css files.",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions test/deps-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ describe( 'Basic Grab Functions', () => {

describe( 'License.txt test.', () => {
it( 'LICENSE.txt', () => {
assert.deepEqual( grabDeps( 'test/src/js/no-comment.js' ).deps, [ 'jquery', 'wp-element', 'wp-i18n' ] );
assert.deepEqual( grabDeps( 'test/src/js/no-comment.js' ).deps, [ 'jquery', 'jquery-ui-datepicker', 'wp-element', 'wp-i18n' ] );
} );
it( 'mit.txt', () => {
assert.deepEqual( grabDeps( 'test/src/js/no-comment.js', '.mit.txt' ).deps, [ 'jquery', 'wp-element', 'wp-blocks' ] );
assert.deepEqual( grabDeps( 'test/src/js/no-comment.js', '.mit.txt' ).deps, [ 'jquery', 'jquery-ui-datepicker', 'wp-element', 'wp-blocks' ] );
} );
it( 'function.txt', () => {
assert.deepEqual( grabDeps( 'test/src/js/no-comment.js', ( file ) => {
return file.replace( '.js', '-license.txt' );
} ).deps, [ 'jquery', 'wp-element', 'scriptaculous' ] );
} ).deps, [ 'jquery', 'jquery-ui-datepicker', 'wp-element', 'scriptaculous' ] );
} );
} );
2 changes: 1 addition & 1 deletion test/src/js/no-comment.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('jquery'), 'version' => '9e20aaa26d4103512888');
<?php return array('dependencies' => array( 'jquery', 'jquery-ui-datepicker' ), 'version' => '9e20aaa26d4103512888');

0 comments on commit e700fca

Please sign in to comment.