Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
grunt-monty-python
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
f08fef4d
authored
2015-07-24 10:57:22 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
wip
1 parent
3c798b39
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
2 deletions
grunt-monty-python.js
package.json
grunt-monty-python.js
View file @
f08fef4
...
...
@@ -9,8 +9,54 @@ module.exports = function (grunt) {
var
_
=
require
(
'lodash'
);
function
createConfig
(
mpConfig
)
{
var
initConfig
=
{};
var
holyGrailTmp
=
'.grunt/holygrail'
;
var
initConfig
=
{
clean
:
{
dist
:
{
files
:
[{
dot
:
true
,
src
:
[
holyGrailTmp
,
'dist/*'
,
'!dist/.git*'
]
}]
},
},
};
var
checkList
=
[];
var
buildList
=
[
'check'
,
'clean:dist'
,
];
function
externalMultiTask
(
name
,
desc
,
command
,
updateOptions
)
{
grunt
.
log
.
writeln
(
'registering multiTask'
,
name
);
grunt
.
registerMultiTask
(
name
,
desc
,
function
()
{
grunt
.
log
.
writeln
(
'foobar'
,
name
);
grunt
.
log
.
writeln
(
'foobar'
,
name
);
var
done
=
this
.
async
();
var
options
=
this
.
options
();
var
target
=
this
.
target
;
var
configFile
=
holyGrailTmp
+
'/configs/'
+
name
+
'-'
+
target
+
'.json'
;
var
commandArgs
=
updateOptions
.
apply
(
this
,
[
target
,
options
,
configFile
]);
grunt
.
file
.
write
(
configFile
,
JSON
.
stringify
(
options
)
+
'\n'
);
grunt
.
log
.
writeln
(
JSON
.
stringify
(
commandArgs
)
+
'\n'
);
require
(
'child_process'
).
execFile
(
command
,
commandArgs
,
function
(
error
,
stdout
,
stderr
)
{
stdout
=
stdout
.
split
(
'\n'
).
map
(
function
(
v
)
{
return
name
+
':'
+
target
+
': '
+
v
;
}).
join
(
'\n'
);
grunt
.
log
.
writeln
(
stdout
);
if
(
error
)
{
stderr
=
stderr
.
split
(
'\n'
).
map
(
function
(
v
)
{
return
name
+
':'
+
target
+
': '
+
v
;
}).
join
(
'\n'
);
grunt
.
log
.
writeln
(
stderr
);
}
done
(
error
);
});
});
}
grunt
.
loadNpmTasks
(
'grunt-monty-python'
);
if
(
mpConfig
.
jshint
)
{
...
...
@@ -48,6 +94,78 @@ module.exports = function (grunt) {
checkList
.
push
(
'htmlmin'
);
}
if
(
common
.
punch
)
{
grunt
.
registerMultiTask
(
'punch'
,
'run punch externally to create html files'
,
function
()
{
var
done
=
this
.
async
();
var
options
=
this
.
options
();
var
target
=
this
.
target
;
//var PunchConfigHandler = require('punch/lib/config_handler');
var
PunchSiteGenerator
=
require
(
'punch/lib/site_generator'
);
var
punchConfig
=
_
.
clone
(
require
(
'punch/lib/default_config'
));
_
.
merge
(
punchConfig
,
options
);
punchConfig
.
output_dir
=
holyGrailTmp
+
'/punch/output-'
+
target
;
punchConfig
.
generator
.
blank
=
false
;
PunchSiteGenerator
.
setup
(
punchConfig
);
grunt
.
log
.
write
(
'foo'
,
punchConfig
);
try
{
PunchSiteGenerator
.
generate
(
function
()
{
grunt
.
log
.
writeln
(
'done generator'
,
arguments
);
done
(
true
);
});
}
catch
(
e
)
{
grunt
.
log
.
writeln
(
'fail'
,
e
);
done
(
false
);
}
});
initConfig
.
punch
=
{
options
:
{
'template_dir'
:
'src/punch/templates'
,
'content_dir'
:
'src/punch/contents'
,
plugins
:
{
parsers
:
{
'.html'
:
'punch-html-fragment-content-parser'
,
},
},
bundles
:
{
},
},
generate
:
{
},
};
buildList
.
push
(
'punch:generate'
);
}
buildList
.
push
(
'useminPrepare'
);
// html
//buildList.push('usemin:views'
buildList
.
push
(
'requirejs'
);
// script
buildList
.
push
(
'copy:css'
);
// css
buildList
.
push
(
'imagemin'
);
// image
buildList
.
push
(
'svgmin'
);
// image
buildList
.
push
(
'rev:img'
);
// image
buildList
.
push
(
'autoprefixer'
);
// css
/*
'concat:requirejs', // montyPython
'concat:generated', // montyPython
'cssmin', // montyPython
//'uglify:dist',
'copy:dist',
//'modernizr',
'uglify:generated', // montyPython
//'rev:dist', // montyPython
'rev:css', // montyPython
'revconfig', // montyPython
'uglify:bower', // montyPython
'uglify:requireconfig', // montyPython
'rev:requireconfig', // montyPython
'usemin:html', // montyPython
'usemin:css', // montyPython
'htmlmin', // montyPython
*/
grunt
.
initConfig
(
initConfig
);
grunt
.
registerTask
(
'check'
,
checkList
);
...
...
@@ -56,6 +174,7 @@ module.exports = function (grunt) {
'check'
,
]);
grunt
.
registerTask
(
'build'
,
buildList
);
}
return
{
...
...
package.json
View file @
f08fef4
...
...
@@ -16,10 +16,13 @@
"main"
:
"grunt-monty-python"
,
"dependencies"
:
{
"grunt"
:
"~0"
,
"grunt-contrib-clean"
:
"~0"
,
"grunt-contrib-csslint"
:
"~0"
,
"grunt-contrib-jshint"
:
"~0"
,
"grunt-contrib-htmlmin"
:
"~0"
,
"lodash"
:
"~2"
"lodash"
:
"~2"
,
"punch"
:
"~0.5.46"
,
"punch-html-fragment-content-parser"
:
"^0.5.1"
},
"devDependencies"
:
{
}
...
...
Please
register
or
sign in
to post a comment