Skip to content

Instantly share code, notes, and snippets.

@ldco2016
Created August 22, 2019 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldco2016/aa5eb8db86f9dc671f24780e1147e67d to your computer and use it in GitHub Desktop.
Save ldco2016/aa5eb8db86f9dc671f24780e1147e67d to your computer and use it in GitHub Desktop.
script
#!/usr/bin/env node
const replace = require("replace-in-file");
const path = require("path");
const argv = require("yargs")
.env("APPCENTER")
.option("k", {
alias: "key"
})
.option("p", {
alias: "platform"
}).argv;
const androidPath = path.join(
__dirname,
"..",
"android",
"app",
"src",
"main",
"assets",
"appcenter-config.json"
);
const iosPath = path.join(
__dirname,
"..",
"ios",
"NFIBEngage",
"AppCenter-Config.plist"
);
const { key, platform } = argv;
try {
if (key && platform) {
const androidOptions = {
files: androidPath,
from: /\S{8}-\S{4}-\S{4}-\S{4}-\S{12}/,
to: key
};
const iosOptions = {
files: iosPath,
from: /\S{8}-\S{4}-\S{4}-\S{4}-\S{12}/,
to: key
};
const options =
platform && platform.toLowerCase() === "android"
? androidOptions
: iosOptions;
const changes = replace.sync(options);
console.log("Modified files:", changes.join(", "));
}
} catch (e) {
console.log("============================================================");
console.log("Error generating file");
console.log("============================================================");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment