csantanapr / grunt-cordovacli

Wraps web app with Cordova CLI using GruntJS
Apache License 2.0
60 stars 31 forks source link

Working Directory is not a Cordova-based project from Grunt #5

Closed paranoid-android closed 10 years ago

paranoid-android commented 10 years ago

I have a web-app that I build via Grunt. Now, I want to bundle that app as part of my build process using PhoneGap/Cordova. In an attempt to do that, I've included the grunt-cordovacli module and have a target called 'deploy'. Deploy is setup like this:

grunt.registerTask('deploy', [
  'build',
  'cordovacli:add_platforms',
  'cordovacli:add_plugins', 
  'cordovacli:prepare_ios',
  'cordovacli:prepare_android', 
  'cordovacli:prepare_windows',
  'cordovacli:build_ios',
  'cordovacli:build_android',
  'cordovacli:build_windows'
]);

I've confirmed build works by loading the content in my browser. My cordovacli task is configured as follows:

module.exports = function(config) {
  return {
    options: {
      path: '/distribute'
    },
    cordova: {
      options: {
        command: ['prepare', 'create','platform','plugin','build'],
        platforms: ['ios','android', 'wp8'],
        plugins: ['device','dialogs'],
        path: '/distribute',
        id: 'myco.myapp',
        name: 'myapp'
      }
    }
    add_platforms: {
      options: {
        command: 'platform',
        action: 'add',
        platforms: ['ios', 'android', 'wp8']
      }
    },
    add_plugins: {
      options: {
        command: 'plugin',
        action: 'add',
        plugins: [
          'battery-status',
          'camera',
          'contacts',
          'splashscreen'
        ]
      }
    },
    build_ios: {
      options: {
        command: 'build',
        platforms: ['ios']
      }
    },
    build_android: {
      options: {
        command: 'build',
        platforms: ['android']
      }
    },
    build_windows: {
      options: {
        command: 'build',
        platforms: ['wp8']
      }
    },
    prepare_ios: {
      options: {
        command: 'prepare',
        platforms: ['ios']
      }
    },
    prepare_android: {
      options: {
        command: 'prepare',
        platforms: ['android']
      }
    }
  };
};

When I run deploy, everything works up until the cordova stuff. At that point, I get the following:

Running "cordovacli:add_platforms" (cordovacli) task
Using cordova CLI version (3.5.0-0.2.6)
Setting Current Working Directory (CWD) to distribute
Running:node C:\Projects\myapp\node_modules\grunt-cordovacli\node_modules\cordova\bin\cordova platform add ios
Running:node C:\Projects\myapp\node_modules\grunt-cordovacli\node_modules\cordova\bin\cordova platform add android
Running:node C:\Projects\myapp\node_modules\grunt-cordovacli\node_modules\cordova\bin\cordova platform add wp8
Current working directory is not a Cordova-based project.
>> Error
Error-> with Parallel tasksError

This bug is being experienced on a Windows 8 machine.