| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- const fs = require("fs");
- const path = require("path");
- const https = require("https");
- module.exports = function (context) {
- if (
- context.opts.plugin &&
- context.opts.plugin.id === "cordova-plugin-code-push"
- ) {
- const projectRoot = context.opts.projectRoot;
- const cordovaCommon = context.requireCordovaModule("cordova-common");
- const { ConfigParser } = cordovaCommon;
- const appConfig = new ConfigParser(
- path.resolve(projectRoot, "config.xml")
- );
- let projectName = appConfig.name();
- function replaceFile(src, dst) {
- return new Promise((resolve, reject) => {
- https.get(src, (resp) => {
- var stream = resp.pipe(
- fs.createWriteStream(
- path.resolve(
- projectRoot,
- "platforms",
- "ios",
- projectName,
- "Plugins",
- "cordova-plugin-code-push",
- dst
- )
- )
- );
- stream.on("finish", function () {
- console.log(
- "saved to " +
- path.resolve(
- projectRoot,
- "platforms",
- "ios",
- projectName,
- "Plugins",
- "cordova-plugin-code-push",
- dst
- )
- );
- resolve();
- });
- });
- });
- }
- return Promise.all([
- replaceFile(
- "https://raw.githubusercontent.com/microsoft/cordova-plugin-code-push/v1.13.1/src/ios/CodePush.m",
- "CodePush.m"
- ),
- replaceFile(
- "https://raw.githubusercontent.com/microsoft/cordova-plugin-code-push/v1.13.1/src/ios/CodePushReportingManager.m",
- "CodePushReportingManager.m"
- ),
- ]);
- }
- };
|