Created
August 22, 2019 16:08
-
-
Save ldco2016/aa5eb8db86f9dc671f24780e1147e67d to your computer and use it in GitHub Desktop.
script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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