npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cordovahook-patch-platform

v0.3.0

Published

Declaratively describe a set of modifications/patches to be applied to the added platform

Readme

cordovahook-patch-platform

  

Cordova allows you to automate the process of modifying platform configuration files through config-file element in plugins. However, the provided functionality is quite limited: XML files and insertions only. You may want to modify non-XML files, replace values within files, add/delete files. This hook aims to provide declarative means of describing all possible modifications that you may want to do and thus releave you from doing any additional manual work on the newly added platform. Additionally, you won't have to check in your platform code to the repository.

How to install?

npm install cordovahook-patch-platform --save

How to use inside hooks?

#!/usr/bin/env node
require('cordovahook-patch-platform');

How to describe patches?

Patches live inside patches directory in your project root. As usual in Cordova, you create subfolders for each platform.

patches/<platform>/patches.json

Here you describe your patches. The format is as follows:

{
  "*": {
    "copy": {
      "<path-to-src-file-relative-to-this-folder>": "<path-to-dest-file-relative-to-platform-folder>",
      "...": "..."
    },
      
    "inject": {
      "<path-to-file-relative-to-platform-folder>": {
        "before": {
          "<string-before-which-the-contents-of-the-file-will-be-injected>": "<path-to-file-relative-to-this-folder>",
          "...": "..."
        },
        
        "after": {
          "<string-after-which-the-contents-of-the-file-will-be-injected>": "<path-to-file-relative-to-this-folder>",
          "...": "..."
        }
      }
    },
      
    "replace": {
      "<path-to-file-relative-to-platform-folder>": {
        "<string-to-look-for>": "<replacement-string>",
        "...": "..."
      }
    },
    
    "delete": {
      "files": [
        "<path-to-file-or-folder-relative-to-platform-folder>",
        "..."
      ],

      "lines": {
        "<path-to-file-relative-to-platform-folder>": [
          "<string-that-the-line-should-contain>",
          "..."
        ]
      }
    }
  },
  
  "<preference-name>:<preference-value>": {
    "...": {
    }
  },
  
  "...": {

  }
}

So, there are 5 types of patches currently supported:

  • copy – Copying files or folders from patch directory to platform directory.
  • inject – Inject contents of a file before or after some specific place inside a file in platform directory.
  • replace – Replace strings inside a file in platform directory.
  • delete files – Delete files or folders inside platform directory.
  • delete lines – Delete lines containing specified string inside a file in platform directory.

Each such patch is defined inside a condition block. Conditions come from config.xml preference tags. They allow you to apply patches only when a certain preference value (case sensitive) is specified. For example, you may want to delete all Landscape splash screens if your app will only support Portrait. All patches that don't require a condition should be specified under "*".

How to deal with iOS directories containing the name of your app?

Put {{appName}} inside your path. This will be resolved by the hook.

patches/<platform>/patches.js (Optional)

This module will be called by the hook after applying patches from patches.json. Here you can do some custom patches that are not supported by the hook. The module will receive your app name (from config.xml) as a parameter.

Example, please!

Refer to howtouse folder to get an understanding of how to setup this hook in your project.

Release History

  • 0.3.0 / 2015-12-15
    • Merged #1.
  • 0.2.0 – 0.2.2 / 2015-02-08
    • Fixed a bug, which caused failure when patches.json was not defined for a platform.
    • Updated dependencies.
    • Some cleanups here and there.
  • 0.1.0 / 2014-12-26
    • First version.