Skip to content

Commit

Permalink
support RequireJS. closes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan committed Jul 7, 2012
1 parent e305db6 commit ced24c5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
7 changes: 1 addition & 6 deletions src/xregexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1485,14 +1485,9 @@ var XRegExp = (function () {
);

/*--------------------------------------
* Expose XRegExp
* Return XRegExp
*------------------------------------*/

// For CommonJS enviroments
if (typeof exports === 'object') {
exports.XRegExp = self;
}

return self;

}());
24 changes: 10 additions & 14 deletions tools/concatenate-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
# Allow running this script from another directory
cd "$(dirname "$0")"

# Ordered list of all source files excluding backcompat.js
# Ordered list of all source files except backcompat.js
source_files='
./intro.js
../src/xregexp.js
../src/addons/build.js
../src/addons/matchrecursive.js
../src/addons/prototypes.js
../src/addons/unicode/unicode-base.js
../src/addons/unicode/unicode-categories.js
../src/addons/unicode/unicode-scripts.js
../src/addons/unicode/unicode-blocks.js
../src/addons/unicode/unicode-categories.js
../src/addons/unicode/unicode-properties.js
../src/addons/matchrecursive.js
../src/addons/build.js
../src/addons/prototypes.js
../src/addons/unicode/unicode-scripts.js
./outro.js
'

# Filename of concatenated package
Expand All @@ -22,16 +24,10 @@ output_file='../xregexp-all.js'
# Remove output file to re-write it
rm -f $output_file

# Add header comment
echo '/*! XRegExp All */' >> $output_file

# Concatenate all source files
for file in $source_files
do
echo '' >> $output_file
echo "/*---- $(basename $file) ----*/" >> $output_file
echo '' >> $output_file
cat $file >> $output_file
cat $file >> $output_file
done

echo "Succesfully created $(basename $output_file)"
echo "Successfully created $(basename $output_file)"
21 changes: 21 additions & 0 deletions tools/intro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*!
* XRegExp All 2.1.0-rc
* <http://xregexp.com/>
* Steven Levithan © 2012 MIT License
*/

;(function (definition) {
// Don't turn on strict mode for this function, so we can assign to global.XRegExp

// RequireJS
if (typeof define === 'function') {
define(definition);
// CommonJS
} else if (typeof exports === 'object') {
exports.XRegExp = definition();
// <script>
} else {
// Create global
XRegExp = definition();
}
}(function () {
3 changes: 3 additions & 0 deletions tools/outro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return XRegExp;

}));
7 changes: 1 addition & 6 deletions xregexp-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -1506,14 +1506,9 @@ var XRegExp = (function () {
);

/*--------------------------------------
* Expose XRegExp
* Return XRegExp
*------------------------------------*/

// For CommonJS enviroments
if (typeof exports === 'object') {
exports.XRegExp = self;
}

return self;

}());
Expand Down

0 comments on commit ced24c5

Please sign in to comment.