Closed Josh68 closed 10 years ago
No, i've never seen that. Can you pull the repo, install the dependencies, and run grunt
to view the tests of basic configurations?
What grunt/node/os versions are you on?
Did what you asked and all was done without errors. Windows 7, grunt v0.4.2, grunt-cli v0.1.11, node v0.10.22. I'll post my entire GruntFile and package.json. Basically, this is just a local modification of reveal.js that I'm using for a slidedeck, but also as a testing ground for configuring grunt (and gulp as an alternative, in the same project) for a basic task flow that includes spawning a browser window and initializing livereload. Still not at all complex, probably could be written a lot better, and there is no dev/build structure, so src and dist at this point are (or should be) limited to sass compilation, cssmin, and uglify. I'm not sure how I ended up in a situation where grunt-open works with a files/src option but throws errors without it.
/* global module:false, require:false */
module.exports = function(grunt) {
var port = grunt.option('port') || 9000;
//LiveReload Middleware setup
// This is the default port that livereload listens on;
// change it if you configure livereload to use another port.
var LIVERELOAD_PORT = 35729;
// lrSnippet is just a function.
// It's a piece of Connect middleware that injects
// a script into the static served html.
var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT });
// All the middleware necessary to serve static files.
var livereloadMiddleware = function (connect, options) {
return [
// Inject a livereloading script into static files.
lrSnippet,
// Serve static files.
connect.static(options.base),
// Make empty directories browsable.
connect.directory(options.base)
];
};
// Dependencies
require('load-grunt-tasks')(grunt);
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner:
'/*!\n' +
' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
' * http://lab.hakim.se/reveal-js\n' +
' * MIT licensed\n' +
' *\n' +
' * Copyright (C) 2013 Hakim El Hattab, http://hakim.se\n' +
' */'
},
qunit: {
files: [ 'test/*.html' ]
},
uglify: {
options: {
banner: '<%= meta.banner %>\n'
},
build: {
src: 'js/reveal.js',
dest: 'js/reveal.min.js'
}
},
cssmin: {
compress: {
files: {
'css/reveal.min.css': [ 'css/reveal.css' ]
}
}
},
sass: {
main: {
files: {
'css/theme/default.css': 'css/theme/source/default.scss',
'css/theme/beige.css': 'css/theme/source/beige.scss',
'css/theme/night.css': 'css/theme/source/night.scss',
'css/theme/serif.css': 'css/theme/source/serif.scss',
'css/theme/simple.css': 'css/theme/source/simple.scss',
'css/theme/sky.css': 'css/theme/source/sky.scss',
'css/theme/moon.css': 'css/theme/source/moon.scss',
'css/theme/solarized.css': 'css/theme/source/solarized.scss',
'css/theme/blood.css': 'css/theme/source/blood.scss',
'css/theme/mktfed.css': 'css/theme/source/mktfed.scss'
}
}
},
jshint: {
options: {
curly: false,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
eqnull: true,
browser: true,
expr: true,
globals: {
head: false,
module: false,
console: false,
unescape: false
}
},
files: [ 'Gruntfile.js', 'js/reveal.js' ]
},
connect: {
server: {
options: {
port: port,
base: '.',
middleware: livereloadMiddleware,
}
}
},
open: {
all: {
files: { src: ['./index.html'] },
path: 'http://localhost:<%= connect.server.options.port %>',
app: 'chrome'
}
},
zip: {
'reveal-js-presentation.zip': [
'index.html',
'css/**',
'js/**',
'lib/**',
'images/**',
'plugin/**'
]
},
watch: {
main: {
files: [ 'Gruntfile.js', 'index.html', 'js/reveal.js', 'css/reveal.css' ],
tasks: 'default',
options: {
livereload: LIVERELOAD_PORT
}
},
theme: {
files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ],
tasks: 'themes',
options: {
livereload: LIVERELOAD_PORT
}
}
}
});
// Default task
grunt.registerTask( 'default', [ 'jshint', 'cssmin', 'uglify', 'qunit' ] );
// Theme task
grunt.registerTask( 'themes', [ 'sass' ] );
// Package presentation to archive
grunt.registerTask( 'package', [ 'default', 'zip' ] );
// Serve presentation locally
grunt.registerTask( 'serve', [ 'connect', 'open', 'watch' ] );
// Run tests
grunt.registerTask( 'test', [ 'jshint', 'qunit' ] );
{
"name": "reveal.js",
"version": "2.6.1",
"description": "The HTML Presentation Framework",
"homepage": "http://lab.hakim.se/reveal-js",
"subdomain": "revealjs",
"scripts": {
"test": "grunt test",
"start": ""
},
"author": {
"name": "Hakim El Hattab",
"email": "hakim.elhattab@gmail.com",
"web": "http://hakim.se"
},
"repository": {
"type": "git",
"url": "git://github.com/hakimel/reveal.js.git"
},
"engines": {
"node": "~0.8.0"
},
"dependencies": {
"underscore": "~1.5.1",
"express": "~2.5.9",
"mustache": "~0.7.2",
"socket.io": "~0.9.13"
},
"devDependencies": {
"grunt-contrib-qunit": "~0.2.2",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-cssmin": "~0.4.1",
"grunt-contrib-uglify": "~0.2.4",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-sass": "~0.5.0",
"grunt-contrib-connect": "~0.4.1",
"grunt-zip": "~0.7.0",
"grunt": "~0.4.0",
"gulp": "~3.3.0",
"gulp-util": "~2.2.9",
"tiny-lr": "0.0.5",
"gulp-livereload": "~0.1.1",
"gulp-watch": "~0.3.3",
"gulp-sass": "~0.2.3",
"gulp-open": "~0.2.7",
"connect": "~2.12.0",
"http-server": "~0.6.1",
"compression": "~1.0.0",
"watch-connect": "~0.3.4",
"express": "~3.4.7",
"socket.io": "~0.9.16",
"connect-livereload": "~0.3.2",
"gulp-jade": "~0.3.0",
"gulp-imagemin": "~0.1.4",
"gulp-csso": "~0.1.7",
"grunt-reload": "~0.2.0",
"load-grunt-tasks": "~0.2.1",
"grunt-open": "~0.2.2"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/hakimel/reveal.js/blob/master/LICENSE"
}
]
}
On an entirely unrelated note, is there a way to pass flags to the app config?
Thanks, and sorry if this is a simple mistake somewhere on my part, which it probably is.
There's a bit too much there to just read through, do you have a repo that I can clone to debug?
I doubt it's an issue with grunt-open since it's such a basic task, but i can help troubleshoot a bit.
Sorry: https://github.com/Josh68/moda_marketing_fed
Don't want to waste your time on it, but if you feel inclined to check it out, you might be better at debugging grunt than I was. I was really wondering whether anyone else had run into that kind of situation. Thanks.
Removing that line and running grunt serve --stack
shows that grunt-zip (and a dependency grunt-retro?) are throwing the error
[11:09:10] 3 $ grunt serve --stack
Running "connect:server" (connect) task
Started connect web server on 127.0.0.1:9000.
Running "open:all" (open) task
Warning: Cannot read property 'orig' of undefined Use --force to continue.
TypeError: Cannot read property 'orig' of undefined
at Object.proxiedTaskFn (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt-zip/node_modules/grunt-retro/tasks/retro.js:42:34)
at Object.<anonymous> (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt/lib/grunt/task.js:264:15)
at Object.thisTask.fn (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt/lib/grunt/task.js:82:16)
at Object.<anonymous> (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt/lib/util/task.js:282:30)
at Task.runTaskFn (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt/lib/util/task.js:235:24)
at Task.<anonymous> (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt/lib/util/task.js:281:12)
at Task.<anonymous> (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt/lib/util/task.js:215:7)
at Task.runTaskFn (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt/lib/util/task.js:238:9)
at Task.<anonymous> (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt/lib/util/task.js:281:12)
at Task.<anonymous> (/Users/joverson/development/src/tmp/moda_marketing_fed/node_modules/grunt/lib/util/task.js:215:7)
Aborted due to warnings.
I'd guess this is due to grunt-retro not playing nicely with grunt 0.4 configs and is probably not worth troubleshooting if you can get rid of it (or grunt-zip in favor of grunt-contrib-compress maybe)
Thanks for the follow-up. Now a really stupid question. Why was the zip task being invoked by the serve task, or is that actually what was happening? Was it just running through the registration of all tasks and throwing that error when registering the package task ['default', 'zip']? I swapped out zip for grunt-contrib-compress, setup a similar config, and open is now working as expected without any extra files config line.
it probably wasn't, it was probably an aggressive overreach of grunt-retro which was only noticed when a task chain with open
was run.
Hmmm, i'll have to dig down into the code to see how that might have been happening. Well, thanks again for looking into it, and it was resolved by switching over to grunt-contrib-compress.
Just mucking around here trying to get a configuration together that starts my server, sets up watches, and opens a browser. I couldn't get grunt-open to work for the longest time, and was getting errors "cannot read property 'orig' of undefined" on the multiTask defined in the module. When I changed the multiTask to a plain task (registerTask), I started getting "cannot read property 'url' of undefined." Reading around, I found some hints that the module might be expecting a "files:" config, even though it's not documented. In the end, I came up with this (using this specific syntax), and everything finally worked:
Any ideas why I was having this issue? I don't see that anyone else has encountered it. Thanks, and thanks for the package.