Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Update grunt modules with getPackage()
Browse files Browse the repository at this point in the history
  • Loading branch information
interactivellama committed Aug 18, 2015
1 parent eea13a6 commit 08f4d4f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
8 changes: 6 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ module.exports = function (grunt) {
* since it has not been initialized yet, until grunt.initConfig() is executed.
*/

function getPackage() {
return grunt.file.readJSON('./package.json');
}

// use --no-livereload to disable livereload. Helpful to 'serve' multiple projects
var isLivereloadEnabled = (typeof grunt.option('livereload') !== 'undefined') ? grunt.option('livereload') : true;

// external libraries
var semver = require('semver');
var packageVersion = require('./package.json').version;
var packageVersion = getPackage().version;
var fs = require('fs');
var path = require('path');
var commonJSBundledReferenceModule = require('./grunt/other/commonjs-reference-module.js');
Expand Down Expand Up @@ -49,7 +53,7 @@ module.exports = function (grunt) {
jqueryCheck: 'if (typeof jQuery === \'undefined\') { throw new Error(\'Fuel UX\\\'s JavaScript requires jQuery\') }\n\n',
bootstrapCheck: 'if (typeof jQuery.fn.dropdown === \'undefined\' || typeof jQuery.fn.collapse === \'undefined\') ' +
'{ throw new Error(\'Fuel UX\\\'s JavaScript requires Bootstrap\') }\n\n',
pkg: grunt.file.readJSON('package.json'),
pkg: getPackage(),
// Try ENV variables (export SAUCE_ACCESS_KEY=XXXX), if key doesn't exist, try key file
sauceLoginFile: grunt.file.exists('SAUCE_API_KEY.yml') ? grunt.file.readYAML('SAUCE_API_KEY.yml') : undefined,
cdnLoginFile: grunt.file.exists('FUEL_CDN.yml') ? grunt.file.readYAML('FUEL_CDN.yml') : undefined,
Expand Down
11 changes: 8 additions & 3 deletions grunt/config/less.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ module.exports = function (grunt) {

var minifiedOutput = 'dist/css/' + '<%= pkg.name %>' + '.min.css';

var minifyFiles = function() {
var minifyFiles = {};
var output = 'dist/css/' + '<%= pkg.name %>' + '.min.css'
minifyFiles[output] = 'dist/css/' + '<%= pkg.name %>' + '.css'
return minifyFiles
};

return {
dev: {
options: {
Expand Down Expand Up @@ -33,9 +40,7 @@ module.exports = function (grunt) {
compress: true,
report: 'min'
},
files: {
minifiedOutput : 'dist/css/' + '<%= pkg.name %>' + '.css'
}
files: minifyFiles()
}
}

Expand Down
6 changes: 5 additions & 1 deletion grunt/config/replace.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
module.exports = function (grunt) {

function getPackage() {
return grunt.file.readJSON('./package.json');
}

return {
readme: {
src: ['DETAILS.md', 'README.md'],
overwrite: true,
replacements: [{
from: /fuelux\/\d\.\d\.\d/g,
to: 'fuelux/' + grunt.config('pkg.version')
to: 'fuelux/' + getPackage().version
}]
}
}
Expand Down
12 changes: 7 additions & 5 deletions grunt/config/saucelabs-qunit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = function (grunt) {
var packageVersion = require('../../package.json').version;
function getPackage() {
return grunt.file.readJSON('./package.json');
}

return {
trickyBrowsers: {
Expand All @@ -10,7 +12,7 @@ module.exports = function (grunt) {
testInterval: 3000,
tags: ['<%= sauceUser %>' + '@' + process.env.TRAVIS_BRANCH || '<%= sauceUser %>' + '@local'],
browsers: grunt.file.readYAML('sauce_browsers_tricky.yml'),
build: process.env.TRAVIS_BUILD_NUMBER || '<%= pkg.version %>',
build: process.env.TRAVIS_BUILD_NUMBER || getPackage().version,
testname: process.env.TRAVIS_JOB_ID || Math.floor((new Date()).getTime() / 1000 - 1230768000).toString(),
urls: ['http://localhost:<%= connect.testServer.options.port %>/test/?testdist=true']
}
Expand All @@ -21,10 +23,10 @@ module.exports = function (grunt) {
key: '<%= sauceKey %>',
tunnelTimeout: 45,
testInterval: 3000,
tags: [packageVersion, '<%= sauceUser %>' + '@' + process.env.TRAVIS_BRANCH || '<%= sauceUser %>@local'],
tags: [getPackage().version, '<%= sauceUser %>' + '@' + process.env.TRAVIS_BRANCH || '<%= sauceUser %>@local'],
browsers: grunt.file.readYAML('sauce_browsers.yml'),
build: process.env.TRAVIS_BUILD_NUMBER || packageVersion,
testname: process.env.TRAVIS_JOB_ID || packageVersion + '-<%= grunt.template.today("dddd, mmmm dS, yyyy, h:MM:ss TT") %>',
build: process.env.TRAVIS_BUILD_NUMBER || getPackage().version,
testname: process.env.TRAVIS_JOB_ID || getPackage().version + '-<%= grunt.template.today("dddd, mmmm dS, yyyy, h:MM:ss TT") %>',
urls: ['http://localhost:<%= connect.testServer.options.port %>/test/?testdist=true'],
maxPollRetries: 4,
throttled: 3,
Expand Down
8 changes: 6 additions & 2 deletions grunt/config/shell.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = function (grunt) {
var semver = require('semver');

function getPackage() {
return grunt.file.readJSON('./package.json');
}

return {
// Compile release notes while waiting for tests to pass. Needs Ruby gem and ONLY LOOKS AT THE REMOTE NAMED ORIGIN.
// Install with: gem install github_changelog_generator
Expand Down Expand Up @@ -30,14 +34,14 @@ module.exports = function (grunt) {
},
commit: {
command: function() {
var command = 'git commit -m "release ' + grunt.config('pkg.version') + '"';
var command = 'git commit -m "release ' + getPackage().version + '"';
grunt.log.write('Committing: ' + command);
return command;
}
},
tag: {
command: function() {
var command = 'git tag -a "' + grunt.config('pkg.version') + '" -m "' + grunt.config('pkg.version') + '"';
var command = 'git tag -a "' + getPackage().version + '" -m "' + getPackage().version + '"';
grunt.log.write('Tagging: ' + command);
return command;
}
Expand Down

0 comments on commit 08f4d4f

Please sign in to comment.