Created
May 21, 2015 12:52
-
-
Save rxaviers/1d24581d986796a06c21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Gruntfile.js b/Gruntfile.js | |
index a10a39a..396c33e 100644 | |
--- a/Gruntfile.js | |
+++ b/Gruntfile.js | |
@@ -88,22 +88,28 @@ grunt.registerTask( "build-demos", function() { | |
return a.title.toLowerCase() > b.title.toLowerCase() ? 1 : -1; | |
} | |
- // We hijack the jquery-ui checkout from download.jqueryui.com | |
- this.requires( "build-download" ); | |
+ var repoDir = userPassedViaGruntArgument; | |
+ if ( !repoDir ) { | |
+ | |
+ // We hijack the jquery-ui checkout from download.jqueryui.com | |
+ this.requires( "build-download" ); | |
+ repoDir = require( "download.jqueryui.com" ).JqueryUi.getStable().path; | |
+ } | |
+ | |
+ repoDir = path.normalize( repoDir ); | |
var jqueryCore, subdir, | |
path = require( "path" ), | |
cheerio = require( "cheerio" ), | |
- downloadBuilder = require( "download.jqueryui.com" ), | |
- stable = downloadBuilder.JqueryUi.getStable(), | |
- repoDir = path.normalize( stable.path ), | |
demosDir = repoDir + "demos", | |
externalDir = (repoDir + "external").replace( process.cwd() + "/", "" ), | |
targetDir = grunt.config( "wordpress.dir" ) + "/resources/demos", | |
highlightDir = targetDir + "-highlight", | |
demoList = {}; | |
- jqueryCore = stable.files().jqueryCore[ 0 ].data.match( /jQuery JavaScript Library v([0-9.]*)/ )[ 1 ]; | |
+ var pkg = require( repoDir + "/package" ); | |
+ var jqueryCore = fs.readFileSync( repoDir + "/external/jquery/jquery.js" ) | |
+ .toString().match( /jQuery JavaScript Library v([0-9.]*)/ )[ 1 ]; | |
// Copy all demos files to /resources/demos | |
grunt.file.recurse( demosDir, function( abspath, rootdir, subdir, filename ) { | |
@@ -168,7 +174,7 @@ grunt.registerTask( "build-demos", function() { | |
// including the full line | |
source = source.replace( | |
/<script src="\.\.\/\.\.\/ui\/[^>]+>/, | |
- "<script src=\"//code.jquery.com/ui/" + stable.pkg.version + "/jquery-ui.js\">" ); | |
+ "<script src=\"//code.jquery.com/ui/" + pkg.version + "/jquery-ui.js\">" ); | |
source = source.replace( | |
/^.*<script src="\.\.\/\.\.\/ui\/[^>]+><\/script>\n/gm, | |
"" ); | |
@@ -181,7 +187,7 @@ grunt.registerTask( "build-demos", function() { | |
// ../../ui/themes/* -> CDN | |
source = source.replace( | |
/<link rel="stylesheet" href="\.\.\/\.\.\/themes[^>]+>/, | |
- "<link rel=\"stylesheet\" href=\"//code.jquery.com/ui/" + stable.pkg.version + "/themes/smoothness/jquery-ui.css\">" ); | |
+ "<link rel=\"stylesheet\" href=\"//code.jquery.com/ui/" + pkg.version + "/themes/smoothness/jquery-ui.css\">" ); | |
// ../demos.css -> /resources/demos/style.css | |
source = source.replace( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment