Skip to content

Commit

Permalink
fix: issue script
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Jan 12, 2023
1 parent 46e05d5 commit 9caca1b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
21 changes: 11 additions & 10 deletions src/bin/android.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
export const readVersion = contents => {
const marketingVersionString = contents.match(/String PLUGIN_VERSION = "(.*)";/);
const version = marketingVersionString.toString();
const regexAndroid = /String\sPLUGIN_VERSION\s=\s"(.*)";/g;

export function readVersion(contents) {
const marketingVersionString = contents.match(regexAndroid);
const version = marketingVersionString
? marketingVersionString[0].replace(regexAndroid, '$1')
: null;
return version;
};
}

export const writeVersion = (contents, version) => {
const newContent = contents.replace(
/String PLUGIN_VERSION = ".*";/g,
`String PLUGIN_VERSION = "${version}";`
);
export function writeVersion(contents, version) {
const newContent = contents.replace(regexAndroid, `String PLUGIN_VERSION = "${version}";`);
return newContent;
};
}
4 changes: 2 additions & 2 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ async function run() {
try {
// merge base config with user config
const { iosPath, androidPath } = await findPathPlugin();
baseConfig.bumpFiles[0].filename = iosPath;
baseConfig.bumpFiles[1].filename = androidPath;
baseConfig.bumpFiles[0].filename = androidPath;
baseConfig.bumpFiles[1].filename = iosPath;
const finalConfig = merge(command.argv, baseConfig);
await standardVersion(finalConfig);
} catch (error) {
Expand Down
18 changes: 8 additions & 10 deletions src/bin/ios.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
export const readVersion = contents => {
const marketingVersionString = contents.match(/let PLUGIN_VERSION = "(.*)"/);
const version = marketingVersionString.toString();
const regexIos = /let\sPLUGIN_VERSION:\sString\s=\s"(.*)"/g;
export function readVersion(contents) {
const marketingVersionString = contents.match(regexIos);
const version = marketingVersionString ? marketingVersionString[0].replace(regexIos, '$1') : null;
return version;
};
}

export const writeVersion = (contents, version) => {
const newContent = contents.replace(
/let PLUGIN_VERSION = ".*"/g,
`let PLUGIN_VERSION = "${version}"`
);
export function writeVersion(contents, version) {
const newContent = contents.replace(regexIos, `let PLUGIN_VERSION = "${version}"`);
return newContent;
};
}

0 comments on commit 9caca1b

Please sign in to comment.