cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patrickbussmann <...@git.apache.org>
Subject [GitHub] cordova-plugin-geolocation issue #86: Add required=false to the uses-feature
Date Thu, 16 Mar 2017 15:44:58 GMT
Github user patrickbussmann commented on the issue:

    https://github.com/apache/cordova-plugin-geolocation/pull/86
  
    You can add this line to your `config.xml`.
    
        <hook type="before_compile" src="hooks/before_compile/change_required_features_to_optional.js"
/>
    
    With this content.
    
      #!/usr/bin/env node
      
      module.exports = function (context) {
        var
          Q = context.requireCordovaModule('q'),
          deferral = new Q.defer(),
          fs = context.requireCordovaModule('fs'),
          path = context.requireCordovaModule('path'),
          platformRoot = path.join(context.opts.projectRoot, 'platforms/android'),
          manifestFile = path.join(platformRoot, 'AndroidManifest.xml')
        ;
      
        if (fs.existsSync(manifestFile)) {
          fs.readFile(manifestFile, 'utf8', function (err, data) {
            if (err) {
              deferral.resolve();
              throw new Error('Unable to find AndroidManifest.xml: ' + err);
            }
      
            fs.writeFile(manifestFile, (function (str) {
              str = str.replace(/android:required="true"/ig, 'android:required="false"');
              str = str.replace(/<uses-feature android:name="([^"]+)" ?\/>/ig, '<uses-feature
android:name="$1" android:required="false" />');
              return str;
            })(data), 'utf8', function (err) {
              deferral.resolve();
              if (err) throw new Error('Unable to write into AndroidManifest.xml: ' + err);
            });
          });
        } else {
          deferral.resolve();
        }
      
        return deferral.promise;
      };
    
    Then it will work fine and you will have no more dependencies :+1: 
    
    But yes your pull request should be merged as soon as possible :+1:


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message