Skip to content

Commit 4ce1b1d

Browse files
authored
Build: Fix copying top-level demos files
* Build: Remove dead code, make the `external` variable local 1. Remove the `externalDir` variable that was computed but not used. 2. Remove the local unused `globalize` variable. 3. Declare the local `external` variable - previously, build code was overwriting the `external` global. * Build: Fix copying top-level demos files The logic to copy files from demos was faulty for top-level files - it was copying them to the `undefined` subdirectory. This is now fixed. Also, dot-files are no longer copied; we don't need the ESLint config copied, for example. Closes gh-216 Ref jquery/jquery-ui#2274
1 parent cd31d4f commit 4ce1b1d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Gruntfile.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ grunt.registerTask( "build-demos", function() {
105105
return a.title.toLowerCase() > b.title.toLowerCase() ? 1 : -1;
106106
}
107107

108-
var demosDir, externalDir, jqueryCore, repoDir, pkg, subdir,
108+
var demosDir, jqueryCore, repoDir, pkg, subdir,
109109
path = require( "path" ),
110110
cheerio = require( "cheerio" ),
111111
targetDir = grunt.config( "wordpress.dir" ) + "/resources/demos",
@@ -123,21 +123,24 @@ grunt.registerTask( "build-demos", function() {
123123
repoDir = path.resolve( repoDir );
124124

125125
demosDir = path.join( repoDir, "demos" );
126-
externalDir = path.join( repoDir, "external" ).replace( process.cwd() + "/", "" );
127126
pkg = require( path.join( repoDir, "package" ) );
128127
jqueryCore = fs.readFileSync( path.join( repoDir, "external/jquery/jquery.js" ) )
129128
.toString().match( /jQuery JavaScript Library v([0-9.]*)/ )[ 1 ];
130129

131130
// Copy all demos files to /resources/demos
132131
grunt.file.recurse( demosDir, function( abspath, rootdir, subdir, filename ) {
132+
if ( filename.startsWith( "." ) ) {
133+
return;
134+
}
135+
133136
if ( filename === "index.html" ) {
134137
return;
135138
}
136139

137140
var content, $,
138-
destDir = targetDir + "/" + subdir + "/",
141+
destDir = `${ targetDir }${ subdir ? `/${ subdir }` : "" }/`,
139142
dest = destDir + filename,
140-
highlightDest = highlightDir + "/" + subdir + "/" + filename;
143+
highlightDest = `${ highlightDir }${ subdir ? `/${ subdir }` : "" }/${ filename }`;
141144

142145
if ( /html$/.test( filename ) ) {
143146
content = replaceResources( grunt.file.read( abspath ) );
@@ -180,7 +183,7 @@ grunt.registerTask( "build-demos", function() {
180183
grunt.file.write( targetDir + "/demo-list.json", JSON.stringify( demoList, null, "\t" ) );
181184

182185
function deAmd( $, destDir ) {
183-
var i18n, globalize,
186+
var i18n, external,
184187
bootstrap = $( "script[src='../bootstrap.js']" ),
185188
require = $( "script[src='../../external/requirejs/require.js']" ),
186189
extra = bootstrap.attr( "data-modules" );

0 commit comments

Comments
 (0)