Platform specific Hooks

How can I create a hook that only runs when adding the android platform but not ios?

is there a way to catch the “ios” keyword from “ionic platform add ios” in the hook?

1 Like

Yup,

#!/usr/bin/env node
var path = require("path"),
  fs = require("fs"),
  rootdir = process.argv[2],
  platforms = process.env.CORDOVA_PLATFORMS;


if (platforms == "ios") {
  console.log("code for iOS only");
} else if (platforms == "android") {
  console.log("code for Android only");
} else {
  console.log("code for all platforms");

}

process.exit(0);

process.env.CORDOVA_PLATFORMS; will match what ever platform you are targeting with the cli.

A good place to see what you can use is in the hooks readme

1 Like