Skip to content

Commit 0afed78

Browse files
OttoAllmendingeraider
andcommitted
refactor(scripts): convert arrow functions to standard named function syntax
Ticket: BTC-1947 Co-authored-by: aider <[email protected]>
1 parent de074e7 commit 0afed78

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

scripts/prepare-release.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ let lernaModuleLocations: string[] = [];
1515
let TARGET_SCOPE = '@bitgo-beta';
1616
let filesChanged = 0;
1717

18-
const setLernaModules = async (): Promise<void> => {
18+
async function setLernaModules(): Promise<void> {
1919
const modules = await getLernaModules();
2020
lernaModules = modules.map(({ name }) => name);
2121
lernaModuleLocations = modules.map(({ location }) => location);
22-
};
22+
}
2323

24-
const replacePackageScopes = () => {
24+
function replacePackageScopes() {
2525
// replace all @bitgo packages & source code with alternate SCOPE
2626
const filePaths = [...walk(path.join(__dirname, '../', 'modules')), ...walk(path.join(__dirname, '../', 'webpack'))];
2727
filePaths.forEach((file) => {
2828
filesChanged += changeScopeInFile(file, lernaModules, TARGET_SCOPE);
2929
});
30-
};
30+
}
3131

3232
// modules/bitgo is the only package we publish without an `@bitgo` prefix, so
3333
// we must manually set one
34-
const replaceBitGoPackageScope = () => {
34+
function replaceBitGoPackageScope() {
3535
const cwd = path.join(__dirname, '../', 'modules', 'bitgo');
3636
const json = JSON.parse(readFileSync(path.join(cwd, 'package.json'), { encoding: 'utf-8' }));
3737
json.name = `${TARGET_SCOPE}/bitgo`;
3838
writeFileSync(path.join(cwd, 'package.json'), JSON.stringify(json, null, 2) + '\n');
39-
};
39+
}
4040

4141
/** Small version checkers in place of an npm dependency installation */
4242
function compareversion(version1, version2) {
@@ -73,7 +73,7 @@ function compareversion(version1, version2) {
7373
*
7474
* @param {String | undefined} preid
7575
*/
76-
const incrementVersions = async (preid = 'beta') => {
76+
async function incrementVersions(preid = 'beta') {
7777
const distTags = await getDistTagsForModuleLocations(lernaModuleLocations);
7878
for (let i = 0; i < lernaModuleLocations.length; i++) {
7979
try {
@@ -118,19 +118,19 @@ const incrementVersions = async (preid = 'beta') => {
118118
console.warn(`Couldn't set next version for ${lernaModuleLocations[i]}`, e);
119119
}
120120
}
121-
};
121+
}
122122

123-
const getArgs = () => {
123+
function getArgs() {
124124
const args = process.argv.slice(2) || [];
125125
const scopeArg = args.find((arg) => arg.startsWith('scope='));
126126
if (scopeArg) {
127127
const split = scopeArg.split('=');
128128
TARGET_SCOPE = split[1] || TARGET_SCOPE;
129129
}
130130
console.log(`Preparing to re-target to ${TARGET_SCOPE}`);
131-
};
131+
}
132132

133-
const main = async (preid?: string) => {
133+
async function main(preid?: string) {
134134
getArgs();
135135
await setLernaModules();
136136
replacePackageScopes();
@@ -143,6 +143,6 @@ const main = async (preid?: string) => {
143143
console.error('No files were changed, something must have gone wrong.');
144144
process.exit(1);
145145
}
146-
};
146+
}
147147

148148
main(process.argv.slice(2)[0]);

scripts/verify-release.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { getLernaModules, getDistTags } from './prepareRelease';
55

66
let lernaModuleLocations: string[] = [];
77

8-
const getLernaModuleLocations = async (): Promise<void> => {
8+
async function getLernaModuleLocations(): Promise<void> {
99
const modules = await getLernaModules();
1010
lernaModuleLocations = modules.map(({ location }) => location);
11-
};
11+
}
1212

13-
const verifyPackage = async (dir: string, preid = 'beta'): Promise<boolean> => {
13+
async function verifyPackage(dir: string, preid = 'beta'): Promise<boolean> {
1414
const cwd = dir;
1515
const json = JSON.parse(readFileSync(path.join(cwd, 'package.json'), { encoding: 'utf-8' }));
1616
if (json.private) {
@@ -32,9 +32,9 @@ const verifyPackage = async (dir: string, preid = 'beta'): Promise<boolean> => {
3232
console.warn(`Failed to fetch dist tags for ${json.name}`, e);
3333
return false;
3434
}
35-
};
35+
}
3636

37-
const verify = async (preid?: string) => {
37+
async function verify(preid?: string) {
3838
await getLernaModuleLocations();
3939
for (let i = 0; i < lernaModuleLocations.length; i++) {
4040
const dir = lernaModuleLocations[i];
@@ -43,7 +43,7 @@ const verify = async (preid?: string) => {
4343
return;
4444
}
4545
}
46-
};
46+
}
4747

4848
// e.g. for alpha releases: `npx ts-node ./scripts/verify-beta.ts alpha`
4949
verify(process.argv.slice(2)[0]);

0 commit comments

Comments
 (0)