grunt-jekyll
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -11,2 +11,5 @@ 'use strict'; | ||
jekyll: { | ||
options: { | ||
src: './test/app' | ||
}, | ||
actual: { | ||
@@ -21,5 +24,2 @@ options: { | ||
} | ||
}, | ||
options: { | ||
src: './test/app' | ||
} | ||
@@ -45,2 +45,2 @@ }, | ||
grunt.registerTask('default', 'test'); | ||
}; | ||
}; |
{ | ||
"name": "grunt-jekyll", | ||
"description": "A custom grunt.js plugin that executes jekyll compile and/or watch for you", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"homepage": "https://github.com/dannygarcia/grunt-jekyll", | ||
@@ -6,0 +6,0 @@ "author": "Danny Garcia <contact@danny-garcia.com> (http://danny-garcia.com)", |
@@ -59,13 +59,6 @@ # grunt-jekyll | ||
Build the site and start a development server. If false, the site is built with the `build` command. | ||
Build the site and start a Jekyll development server on http://localhost:4000. The server lasts forever: kill it with `ctrl+c` | ||
__If you are running a Jekyll version greater than 1.0, you'll want to use this, as server is deprecated.__ | ||
If serve is false, the site is built with the `build` command. | ||
[See Upgrading Jekyll Documentation](http://jekyllrb.com/docs/upgrading/) | ||
#### server | ||
Type: `boolean` | ||
Default: `false` | ||
Build the site and start a development server. If false, the site is built with the `build` command. | ||
For complex projects you may want to use [grunt-contrib-connect](https://github.com/gruntjs/grunt-contrib-connect) instead. | ||
@@ -224,29 +217,19 @@ | ||
v0.4.0: Added setup for tests. | ||
- v0.4.1: Internal optimizations. | ||
- v0.4.0: Added setup for tests. | ||
- v0.3.9: Consolidating branches and bumping version #. | ||
- v0.3.8: Added robwierzbowski's raw option and other PRs. | ||
- v0.3.6: | ||
- Reviewed Jekyll [source](https://github.com/mojombo/jekyll/blob/master/bin/jekyll) and updated plugin with new flags. | ||
- Reviewed and warned about deprecated flags. | ||
- Updated documentation to match flag updates. (Rewritten as a list) | ||
- v0.3.3: Updated link in documentation. Added to-do list. | ||
- v0.3.2: Added option to select config file. Removed deprecated --pygments option flag. Bugfixes. | ||
- v0.3.0: Update for Jekyll 1.0 | ||
- v0.2.1: Fixed destination path option. | ||
- v0.2.0: Updated README with better options. Options are more flexible. | ||
- v0.1.6: Updated README with better example. | ||
- v0.1.0: Initial Release. | ||
v0.3.9: Consolidating branches and bumping version #. | ||
v0.3.8: Added robwierzbowski's raw option and other PRs. | ||
v0.3.6: | ||
- Reviewed Jekyll [source](https://github.com/mojombo/jekyll/blob/master/bin/jekyll) and updated plugin with new flags. | ||
- Reviewed and warned about deprecated flags. | ||
- Updated documentation to match flag updates. (Rewritten as a list) | ||
v0.3.3: Updated link in documentation. Added to-do list. | ||
v0.3.2: Added option to select config file. Removed deprecated --pygments option flag. Bugfixes. | ||
v0.3.0: Update for Jekyll 1.0 | ||
v0.2.1: Fixed destination path option. | ||
v0.2.0: Updated README with better options. Options are more flexible. | ||
v0.1.6: Updated README with better example. | ||
v0.1.0: Initial Release. | ||
## MIT License | ||
@@ -265,1 +248,5 @@ | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/dannygarcia/grunt-jekyll/trend.png)](https://bitdeli.com/free "Bitdeli Badge") | ||
@@ -8,4 +8,4 @@ /*global module*/ | ||
// Create a new multi task | ||
grunt.registerMultiTask('jekyll', 'This triggers the `jekyll` command.', function () { | ||
var done = this.async(); | ||
@@ -39,25 +39,45 @@ var options = this.options(); | ||
}; | ||
var majorVersion; | ||
var rawConfigFile; | ||
function testExists (next) { | ||
var versionCommand = options.bundleExec ? 'bundle exec jekyll -v' : 'jekyll -v'; | ||
exec(versionCommand, function (error, stdout, stderr) { | ||
if (error) { | ||
grunt.fail.warn('Please install Jekyll before running this task.'); | ||
done(false); | ||
} | ||
if (stdout) { | ||
// Stdout returns `jekyll 1.x.x`, match returns first semver digit | ||
majorVersion = stdout.match(/\d+/); | ||
next(); | ||
} | ||
}); | ||
} | ||
// Create temporary config file if needed | ||
function configContext (cb) { | ||
function configContext (next) { | ||
if (options.raw) { | ||
// Tmp file is only available within the context of this function | ||
tmp.file({ prefix: '_config.', postfix: '.yml' }, function (err, path, fd) { | ||
rawConfigFile = path; | ||
if (err) { | ||
return cb(err); | ||
grunt.fail.warn(err); | ||
} | ||
// Write raw to file | ||
fs.writeSync(fd, new Buffer(options.raw), 0, options.raw.length); | ||
cb(null, path); | ||
next(); | ||
}); | ||
} else { | ||
cb(null, null); | ||
} | ||
else { | ||
next(); | ||
} | ||
} | ||
// Run configContext with command processing and execution as a callback | ||
configContext(function (err, path) { | ||
if (err) { | ||
grunt.fail.warn(err); | ||
} | ||
// Run configContext with command execution as a callback | ||
function runJekyll (next) { | ||
@@ -70,8 +90,8 @@ // Build the command string | ||
if (options.serve) { | ||
command += ' serve'; | ||
} else if (options.server) { | ||
command += ' server'; | ||
} else if (options.doctor) { | ||
command += majorVersion > 0 ? ' serve' : ' server'; | ||
} | ||
else if (options.doctor) { | ||
command += ' doctor'; | ||
} else { | ||
} | ||
else { | ||
command += ' build'; | ||
@@ -81,4 +101,4 @@ } | ||
// Insert temporary config path into the config option | ||
if (path) { | ||
options.config = options.config ? options.config + ',' + path : path; | ||
if (typeof rawConfigFile != 'undefined') { | ||
options.config = options.config ? options.config + ',' + rawConfigFile : rawConfigFile; | ||
} | ||
@@ -102,18 +122,30 @@ | ||
// Execute command | ||
grunt.log.write('`' + command + '` was initiated.\n'); | ||
if (options.serve) { | ||
grunt.log.write('Started Jekyll web server on http://localhost:4000. Waiting...\n'); | ||
} | ||
exec(command, function (err, stdout) { | ||
grunt.log.write('\n\nJekyll output:\n' + stdout); | ||
grunt.log.write('\n\nJekyll output:\n'); | ||
grunt.log.write(stdout); | ||
if (err) { | ||
grunt.fail.warn(err); | ||
done(false); | ||
} else { | ||
done(true); | ||
} | ||
else { | ||
next(); | ||
} | ||
}); | ||
} | ||
grunt.log.write('`' + command + '` was initiated.'); | ||
// Run the command | ||
testExists(function() { | ||
configContext (function() { | ||
runJekyll(function() { | ||
done(true); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13529
174
250