diff --git a/tools/combine b/tools/combine index af2be8a..6fc726d 100755 --- a/tools/combine +++ b/tools/combine @@ -142,7 +142,11 @@ if [ "$INC_TEST" ]; then ) # find include files separately so we can output those before the tests - TEST_INC=$( find $PATH_TEST -name 'inc-*.js' -exec basename {} \; ) + TEST_INC=$( + cd "$PATH_TEST" \ + && find . -name 'inc-*.js' \ + | sed 's/^\.\///' \ + ) # include test combine template cat "$TPL_TEST_PATH" | grep -v '^#' | $RMTRAIL @@ -158,6 +162,7 @@ if [ "$INC_TEST" ]; then # prefixing it with "test/" module="${filename%.*}" module="test/${module##*test/}" + module_dir=$( dirname "$module" ) # each module must be enclosed in a closure to emulate a module echo "/** TEST CASE: $testcase **/" @@ -172,7 +177,7 @@ if [ "$INC_TEST" ]; then # add the module, removing trailing commas cat $filename | $RMTRAIL - echo "} )( module['$module'] = {}, 'test' );" + echo "} )( module['$module'] = {}, '$module_dir' );" done echo "};" diff --git a/tools/combine.tpl b/tools/combine.tpl index e4c1625..67496f8 100644 --- a/tools/combine.tpl +++ b/tools/combine.tpl @@ -41,9 +41,8 @@ var easejs = {}; var require = function( module_id ) { // remove the './' directory prefix (every module is currently included - // via a relative path) and stupidly remove single ../'s (combine script - // doesn't include true paths, so they're not necessary to resolve) - var id_clean = module_id.replace( /^\.?\/|\.\.\//, '' ); + // via a relative path), stupidly remove ../'s and remove .js extensions + var id_clean = module_id.replace( /^\.?\/|[^/]*?\/\.\.\/|\.js$/, '' ); // attempt to retrieve the module var mod = module[ id_clean ];