Skip to content

Commit

Permalink
Updates the ssi-task to better use the default grunt tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Angus Perkerson committed Feb 27, 2014
1 parent 484eac5 commit b88de84
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 13 deletions.
16 changes: 7 additions & 9 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,31 @@ module.exports = function(grunt) {

// Configuration to be run (and then tested).
ssi: {
options: {
baseDir: 'test/fixtures/html/',
},
options: {},
default_options: {
options: {},
files: [{
expand: true,
cwd: 'test/fixtures',
src: ['html/**/*.html'],
dest: '.tmp/',
ext: '.html',
src: ['html/*'],
}],
},
custom_options: {
options: {
cacheDir: '',

},
files: [{
expand: true,
cwd: 'test/fixtures',
src: ['html/**/*.html'],
dest: '.tmp/',
ext: '.html',

}],
},
test_default: {
options: {},
options: {
baseDir: 'test/fixtures/html/',
},
files: [{
expand: true,
cwd: 'test/fixtures',
Expand Down
1 change: 0 additions & 1 deletion html/includes/deep/deeper/level2.inc

This file was deleted.

1 change: 1 addition & 0 deletions html/includes/deep/deeper/level3.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Level 3
2 changes: 2 additions & 0 deletions html/includes/deep/level2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Level 2
<!--#include file="deeper/level3.inc" -->
2 changes: 2 additions & 0 deletions html/includes/deep/virtual0.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Virtual 0
<!--#include virtual="levels.html" -->
2 changes: 2 additions & 0 deletions html/includes/level1.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Level 1
<!--#include file="deep/level2.inc" -->
2 changes: 2 additions & 0 deletions html/level0.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Level 0
<!--#include file="includes/level1.inc" -->
2 changes: 2 additions & 0 deletions html/levels.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Start File
<!--#include file="level0.inc" -->
2 changes: 2 additions & 0 deletions html/virtual.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Virtual Start
<!--#include virtual="includes/deep/virtual0.inc" -->
8 changes: 5 additions & 3 deletions tasks/ssi.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = function(grunt) {
cache: false,
ext: '.html',
encoding: 'utf8',
baseDir: process.cwd(),
baseDir: 'html',
};

var options = this.options(defaults);
Expand All @@ -45,17 +45,19 @@ module.exports = function(grunt) {
// Concat specified files.
var src = f.src.filter(function(filepath) {
// Warn on and remove invalid source files (if nonull was set).
if (!grunt.file.exists(filepath)) {
if (!grunt.file.exists(filepath) || grunt.file.isDir(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
} else {
return true;
}
}).forEach(function(filepath) {

grunt.log.writeln('File to process: ' + f.src + ' - ' + filepath + ' dest: ' + f.dest);

var data = ssi.processFile(filepath, options.cache);

var dest = f.dest; // + path.sep + path.basename(filepath, path.extname(filepath)) + options.ext;
var dest = f.dest ? f.dest : path.join('output', filepath); // + path.sep + path.basename(filepath, path.extname(filepath)) + options.ext;

grunt.file.write(dest, data);
grunt.log.writeln('File "' + dest + '" created.');
Expand Down

0 comments on commit b88de84

Please sign in to comment.