From 64adf2fc885d351af95f3d7ca3055462a573c53c Mon Sep 17 00:00:00 2001 From: Mano Swerts Date: Sun, 12 May 2013 00:12:44 +0200 Subject: [PATCH 1/3] Update bowerful.js --- tasks/bowerful.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tasks/bowerful.js b/tasks/bowerful.js index f9ea4a3..5978255 100644 --- a/tasks/bowerful.js +++ b/tasks/bowerful.js @@ -42,6 +42,13 @@ module.exports = function(grunt) { var base = path.join(config.directory, packageName.split('/').pop()); var json = grunt.file.readJSON(path.join(base, 'component.json')); + if (! json.main) { + grunt.log.error(util.format('Package %s did not specify a `main` file in components.json.', packageName)); + grunt.log.error('Trying `bower.json`'); + var content = grunt.file.readJSON(path.join(base, 'bower.json')); + json.main = content.main; + } + if (! json.main) { grunt.log.error(util.format('Package %s did not specify a `main` file in components.json.', packageName)); grunt.log.error('Trying `package.json`'); From 1fe9668fb97ea6c25debaedd2fc7a1a71c05dd41 Mon Sep 17 00:00:00 2001 From: Mano Swerts Date: Sun, 12 May 2013 02:05:17 +0300 Subject: [PATCH 2/3] Update bowerful.js Read bower.js if no component.js exists --- tasks/bowerful.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tasks/bowerful.js b/tasks/bowerful.js index 5978255..7868c4e 100644 --- a/tasks/bowerful.js +++ b/tasks/bowerful.js @@ -40,20 +40,29 @@ module.exports = function(grunt) { } var base = path.join(config.directory, packageName.split('/').pop()); - var json = grunt.file.readJSON(path.join(base, 'component.json')); + var json = {}; + + if (grunt.file.exists(path.join(base, 'component.json'))) { + json = grunt.file.readJSON(path.join(base, 'component.json')); + } if (! json.main) { grunt.log.error(util.format('Package %s did not specify a `main` file in components.json.', packageName)); grunt.log.error('Trying `bower.json`'); - var content = grunt.file.readJSON(path.join(base, 'bower.json')); - json.main = content.main; + + if (grunt.file.exists(path.join(base, 'bower.json'))) { + json = grunt.file.readJSON(path.join(base, 'bower.json')); + } } if (! json.main) { - grunt.log.error(util.format('Package %s did not specify a `main` file in components.json.', packageName)); + grunt.log.error(util.format('Package %s did not specify a `main` file in bower.json.', packageName)); grunt.log.error('Trying `package.json`'); - var content = grunt.file.readJSON(path.join(base, 'package.json')); - json.main = content.main; + + if (grunt.file.exists(path.join(base, 'package.json'))) { + var content = grunt.file.readJSON(path.join(base, 'package.json')); + json.main = content.main; + } } if (! json.main) { From 52ca2018c61a2efc59f86f1279fdf7b316e2cea3 Mon Sep 17 00:00:00 2001 From: Mano Swerts Date: Sun, 12 May 2013 02:17:54 +0300 Subject: [PATCH 3/3] Less verbose --- tasks/bowerful.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tasks/bowerful.js b/tasks/bowerful.js index 7868c4e..4ea6e84 100644 --- a/tasks/bowerful.js +++ b/tasks/bowerful.js @@ -47,8 +47,8 @@ module.exports = function(grunt) { } if (! json.main) { - grunt.log.error(util.format('Package %s did not specify a `main` file in components.json.', packageName)); - grunt.log.error('Trying `bower.json`'); + grunt.log.debug(util.format('Package %s did not specify a `main` file in components.json.', packageName)); + grunt.log.debug('Trying `bower.json`'); if (grunt.file.exists(path.join(base, 'bower.json'))) { json = grunt.file.readJSON(path.join(base, 'bower.json')); @@ -56,8 +56,8 @@ module.exports = function(grunt) { } if (! json.main) { - grunt.log.error(util.format('Package %s did not specify a `main` file in bower.json.', packageName)); - grunt.log.error('Trying `package.json`'); + grunt.log.debug(util.format('Package %s did not specify a `main` file in bower.json.', packageName)); + grunt.log.debug('Trying `package.json`'); if (grunt.file.exists(path.join(base, 'package.json'))) { var content = grunt.file.readJSON(path.join(base, 'package.json')); @@ -66,10 +66,10 @@ module.exports = function(grunt) { } if (! json.main) { - grunt.log.error('Nothing in `package.json`. Reverting to guesswork based on package name.'); + grunt.log.debug('Nothing in `package.json`. Reverting to guesswork based on package name.'); var guess = path.join(base, packageName + '.js'); if (fs.existsSync(guess)) { - grunt.log.error(util.format('%s exists, assuming this is the correct file.', guess)); + grunt.log.debug(util.format('%s exists, assuming this is the correct file.', guess)); json.main = guess; } else { grunt.log.error(util.format('Cannot find main file for %s. Please install manually (or file bug report to %s with your grunt.js).', packageName, 'https://github.com/gyllstromk/grunt-bowerful/issues'));