Skip to content

Commit

Permalink
Add Gruntfile with stylus and intern tasks
Browse files Browse the repository at this point in the history
Also update package.js to exclude Gruntfile and *.styl, and clean up a bit
  • Loading branch information
kfranqueiro committed Feb 16, 2015
1 parent 9fcdac2 commit 2bc176b
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 13 deletions.
65 changes: 65 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,65 @@
/* jshint node:true */

module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('intern-geezer');

// grunt-contrib-stylus does not appear to support globbed destination filenames,
// so generate the desired destination/source configuration ahead of time
var stylusFiles = grunt.file.expand([
'css/dgrid.styl',
'css/TouchScroll.styl',
'css/skins/*.styl',
'!css/skins/skin.styl'
]);
var stylusFilesConfig = {};
stylusFiles.forEach(function (filename) {
stylusFilesConfig[filename.slice(0, -5) + '.css'] = filename;
});

grunt.initConfig({
clean: {
css: {
src: [ 'css/**/*.css' ]
}
},

stylus: {
options: {
compress: false,
use: [ require('nib') ]
},

compile: {
files: stylusFilesConfig
}
},

watch: {
stylus: {
files: [ 'css/**/*.styl' ],
tasks: [ 'stylus' ]
}
},

intern: {
local: {
options: {
runType: 'runner',
config: 'test/intern/intern.local'
}
},
remote: {
options: {
runType: 'runner',
config: 'test/intern/intern'
}
}
}
});

grunt.registerTask('default', [ 'stylus', 'watch:stylus' ]);
grunt.registerTask('test', [ 'intern:local' ]);
};
32 changes: 20 additions & 12 deletions package.js
@@ -1,25 +1,33 @@
/* exported profile */

var miniExcludes = {
'dgrid/CHANGES.md': 1,
'dgrid/LICENSE': 1,
'dgrid/README.md': 1,
'dgrid/package': 1
},
isTestRe = /\/test\//;
var copyOnlyMids = {
'dgrid/Gruntfile': 1,
'dgrid/package': 1
};
var miniExcludeMids = {
'dgrid/CHANGES.md': 1,
'dgrid/LICENSE': 1,
'dgrid/README.md': 1,
'dgrid/Gruntfile': 1,
'dgrid/package': 1
};

var profile = {
resourceTags: {
copyOnly: function (filename, mid) {
return mid in copyOnlyMids;
},

test: function (filename) {
return isTestRe.test(filename);
return /\/test\//.test(filename);
},

miniExclude: function (filename, mid) {
return (/\/(?:test|demos)\//).test(filename) || mid in miniExcludes;
return (/\/(?:test|demos)\//).test(filename) ||
(/\.styl$/).test(filename) ||
mid in miniExcludeMids;
},

amd: function (filename) {
return (/\.js$/).test(filename);
}
}
};
};
7 changes: 6 additions & 1 deletion package.json
Expand Up @@ -18,7 +18,12 @@
"url":"http://github.com/SitePen/dgrid"
},
"devDependencies": {
"intern-geezer": "~2"
"grunt": "0.4.5",
"grunt-contrib-clean": "~0.6.0",
"grunt-contrib-stylus": "~0.20",
"grunt-contrib-watch": "~0.6.1",
"intern-geezer": "~2.2",
"nib": "~1.0.4"
},
"directories": {
"doc": "./doc",
Expand Down

0 comments on commit 2bc176b

Please sign in to comment.