Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
8265fa08
Commit
8265fa08
authored
Jun 05, 2012
by
Rick Waldron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to store custom dist destinations in dist/.destination.json
Signed-off-by:
Rick Waldron
<
waldron.rick@gmail.com
>
parent
e0cdeac8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
18 deletions
+65
-18
.gitignore
.gitignore
+1
-0
README.md
README.md
+14
-0
grunt.js
grunt.js
+50
-18
No files found.
.gitignore
View file @
8265fa08
...
...
@@ -7,6 +7,7 @@ dist
*.patch
/*.html
.DS_Store
dist/.destination.json
dist/.sizecache.json
build/.sizecache.json
node_modules
README.md
View file @
8265fa08
...
...
@@ -98,6 +98,20 @@ With this example, the output files would be:
```
If you want to add a permanent copy destination, create a file in
`dist/`
called ".destination.json". Inside the file, paste and customize the following:
```
json
{
"/Absolute/path/to/other/destination"
:
true
}
```
Additionally, both methods can be combined.
Updating Submodules
-------------------
...
...
grunt.js
View file @
8265fa08
// Resources
// https://gist.github.com/2489540
/**
* Resources
*
* https://gist.github.com/2489540
*
*/
/*global config:true, task:true*/
module
.
exports
=
function
(
grunt
)
{
// readOptionalJSON
// by Ben Alman
// https://gist.github.com/2876125
function
readOptionalJSON
(
filepath
)
{
var
data
=
{};
try
{
data
=
grunt
.
file
.
readJSON
(
filepath
);
grunt
.
log
.
write
(
"Reading data from "
+
filepath
+
"..."
).
ok
();
}
catch
(
e
)
{}
return
data
;
}
var
task
=
grunt
.
task
;
var
file
=
grunt
.
file
;
var
utils
=
grunt
.
utils
;
...
...
@@ -20,6 +36,7 @@ module.exports = function( grunt ) {
grunt
.
initConfig
({
pkg
:
"<json:package.json>"
,
dst
:
readOptionalJSON
(
"dist/.destination.json"
),
meta
:
{
banner
:
"/*! jQuery v@<%= pkg.version %> jquery.com | jquery.org/license */"
},
...
...
@@ -234,32 +251,47 @@ module.exports = function( grunt ) {
// Allow custom dist file locations
grunt
.
registerTask
(
"dist"
,
function
()
{
var
keys
,
dir
;
var
flags
,
paths
,
stored
;
keys
=
Object
.
keys
(
this
.
flags
);
// Check for stored destination paths
// ( set in dist/.destination.json )
stored
=
Object
.
keys
(
config
(
"dst"
)
);
if
(
keys
.
length
)
{
// Allow command line input as well
flags
=
Object
.
keys
(
this
.
flags
);
// If a custom dist dir wasn't specified
// there is nothing to do.
if
(
keys
[
0
]
===
"*"
)
{
return
;
}
// Combine all output target paths
paths
=
[].
concat
(
stored
,
flags
).
filter
(
function
(
path
)
{
return
path
!==
"*"
;
});
dir
=
keys
[
0
];
if
(
!
/
\/
$/
.
test
(
dir
)
)
{
dir
+=
"/"
;
}
// Proceed only if there are actual
// paths to write to
if
(
paths
.
length
)
{
// 'distpaths' is declared at the top of the
// module.exports function scope.
// module.exports function scope. It is an array
// of default files that jQuery creates
distpaths
.
forEach
(
function
(
filename
)
{
var
created
=
dir
+
filename
.
replace
(
"dist/"
,
""
);
paths
.
forEach
(
function
(
path
)
{
var
created
;
if
(
!
/
\/
$/
.
test
(
path
)
)
{
path
+=
"/"
;
}
created
=
path
+
filename
.
replace
(
"dist/"
,
""
);
if
(
!
/^
\/
/
.
test
(
path
)
)
{
log
.
error
(
"File '"
+
created
+
"' was NOT created."
);
return
;
}
file
.
write
(
created
,
file
.
read
(
filename
)
);
file
.
write
(
created
,
file
.
read
(
filename
)
);
log
.
writeln
(
"File '"
+
created
+
"' created."
);
log
.
writeln
(
"File '"
+
created
+
"' created."
);
});
});
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment