mhartington / cordova-config-utils

32 stars 5 forks source link

Fails after changing config.xml name (and no `ionic prepare ios`) #12

Closed janpio closed 8 years ago

janpio commented 8 years ago

I just changed the name in my config.xml to foobar and then wanted to ionic build android. Calling this also executed the hook which failed with this error message:

Running command: "C:\Program Files (x86)\nodejs\node.exe" "C:\...\hooks\afte
r_prepare\011_update_config.js" "C:\..."
C:\...\hooks\after_prepare\011_update_config.js:295
          throw new Error('Failed to parse ' + targetFile + ': ' + err);
          ^

Error: Failed to parse C:\...\platforms\ios\foobar.xcodeproj\projec
t.pbxproj: [object Object]
    at pbxProject.<anonymous> (C:\...\hooks\after_prepare\011_update_config.
js:295:17)
    at emitOne (events.js:77:13)
    at pbxProject.emit (events.js:169:7)
    at pbxProject.<anonymous> (C:\...\node_modules\xcode\lib\pbxProject.js:2
7:18)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at handleMessage (internal/child_process.js:686:10)
    at Pipe.channel.onread (internal/child_process.js:440:11)
ERROR running one or more of the platforms: Error: Hook failed with error code 1: C:\...\hooks\after_prepare\011_update_config.js
You may not have the required environment or OS to run this project

I assume this is because I didn't recreat the iOS part yet and so platforms\ios\foobar.xcodeproj is not present on the file system.

Is there a way around this?

(Of course I just fixed it by running ionic prepare ios, but maybe the hook script should also have a way to fix this)

uaza commented 8 years ago

I have the same problem.

@mhartington Is it possible to change the following lines

    // go through each of the platform directories that have been prepared
    var platforms = _.filter(fs.readdirSync('platforms'), function(file) {
      return fs.statSync(path.resolve('platforms', file)).isDirectory();
    });

with these lines, which includes only the called platforms:

    // go through each of the platform directories that have been prepared
    var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
mhartington commented 8 years ago

Merged