Skip to content

Commit

Permalink
fix: Fix prettier formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeesm committed Jan 23, 2024
1 parent 6aebafe commit 5f01fe7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 55 deletions.
8 changes: 4 additions & 4 deletions src/cmd/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ export default async function run(
reloadStrategy = defaultReloadStrategy,
MultiExtensionRunner = DefaultMultiExtensionRunner,
getValidatedManifest = defaultGetValidatedManifest,
} = {},
} = {}
) {
sourceDir = path.resolve(sourceDir);
log.info(`Running web extension from ${sourceDir}`);
if (preInstall) {
log.info(
"Disabled auto-reloading because it's not possible with " +
'--pre-install',
'--pre-install'
);
noReload = true;
}
Expand Down Expand Up @@ -97,7 +97,7 @@ export default async function run(
if (!profileDir) {
throw new UsageError(
'--profile-create-if-missing requires ' +
'--firefox-profile or --chromium-profile',
'--firefox-profile or --chromium-profile'
);
}
const isDir = fs.existsSync(profileDir);
Expand Down Expand Up @@ -179,7 +179,7 @@ export default async function run(
{
// Suppress the message usually logged by web-ext build.
showReadyMessage: false,
},
}
);
},
};
Expand Down
24 changes: 12 additions & 12 deletions src/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class Program {
0,
0,
undefined,
'This command does not take any arguments',
'This command does not take any arguments'
)
.strict()
.exitProcess(this.shouldExitProgram)
Expand Down Expand Up @@ -283,7 +283,7 @@ export class Program {

if (argv.configDiscovery) {
log.debug(
'Discovering config files. ' + 'Set --no-config-discovery to disable',
'Discovering config files. ' + 'Set --no-config-discovery to disable'
);
const discoveredConfigs = await discoverConfigFiles();
configFiles.push(...discoveredConfigs);
Expand All @@ -303,7 +303,7 @@ export class Program {
log.info(
'Applying config file' +
`${configFiles.length !== 1 ? 's' : ''}: ` +
`${niceFileList}`,
`${niceFileList}`
);
}

Expand Down Expand Up @@ -351,12 +351,12 @@ export class Program {

export async function defaultVersionGetter(
absolutePackageDir,
{ globalEnv = defaultGlobalEnv } = {},
{ globalEnv = defaultGlobalEnv } = {}
) {
if (globalEnv === 'production') {
log.debug('Getting the version from package.json');
const packageData = readFileSync(
path.join(absolutePackageDir, 'package.json'),
path.join(absolutePackageDir, 'package.json')
);
return JSON.parse(packageData).version;
} else {
Expand Down Expand Up @@ -386,7 +386,7 @@ export async function main(
commands = defaultCommands,
argv,
runOptions = {},
} = {},
} = {}
) {
const program = new Program(argv, { absolutePackageDir });
const version = await getVersion(absolutePackageDir);
Expand All @@ -413,7 +413,7 @@ with $${envPrefix}_. For example: $${envPrefix}_SOURCE_DIR=/path is the same as
To view specific help for any given command, add the command name.
Example: $0 --help run.
`,
`
)
.help('help')
.alias('h', 'help')
Expand All @@ -430,7 +430,7 @@ Example: $0 --help run.
default: process.cwd(),
requiresArg: true,
type: 'string',
coerce: (arg) => (arg ?? undefined),
coerce: (arg) => arg ?? undefined,
},
'artifacts-dir': {
alias: 'a',
Expand Down Expand Up @@ -511,15 +511,15 @@ Example: $0 --help run.
arg == null
? undefined
: throwUsageErrorIfArray(
'Multiple --filename/-n option are not allowed',
'Multiple --filename/-n option are not allowed'
)(arg),
},
'overwrite-dest': {
alias: 'o',
describe: 'Overwrite destination package if it exists.',
type: 'boolean',
},
},
}
)
.command(
'sign',
Expand Down Expand Up @@ -586,7 +586,7 @@ Example: $0 --help run.
'details. Only used with `use-submission-api`',
type: 'string',
},
},
}
)
.command('run', 'Run the extension', commands.run, {
target: {
Expand Down Expand Up @@ -820,7 +820,7 @@ Example: $0 --help run.
'docs',
'Open the web-ext documentation in a browser',
commands.docs,
{},
{}
);

return program.execute({ getVersion, ...runOptions });
Expand Down
27 changes: 15 additions & 12 deletions tests/unit/test-cmd/test.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function prepareRun(fakeInstallResult) {
getFakeRemoteFirefox({
installTemporaryAddon: () =>
Promise.resolve(fakeInstallResult || tempInstallResult),
}),
})
);
}),
reloadStrategy: sinon.spy(() => {
Expand Down Expand Up @@ -78,11 +78,11 @@ describe('run', () => {

androidRunnerStub = sinon.stub(
firefoxAndroidModule,
'FirefoxAndroidExtensionRunner',
'FirefoxAndroidExtensionRunner'
);
desktopRunnerStub = sinon.stub(
firefoxDesktopModule,
'FirefoxDesktopExtensionRunner',
'FirefoxDesktopExtensionRunner'
);
chromiumRunnerStub = sinon.stub(chromiumModule, 'ChromiumExtensionRunner');

Expand Down Expand Up @@ -132,7 +132,10 @@ describe('run', () => {
const getFakeManifest = sinon.spy();
const cmd = await prepareRun();

await cmd.run({ sourceDir: '.' }, { getValidatedManifest: getFakeManifest });
await cmd.run(
{ sourceDir: '.' },
{ getValidatedManifest: getFakeManifest }
);

sinon.assert.calledOnce(desktopRunnerStub);
const runnerParams = desktopRunnerStub.firstCall.args[0];
Expand Down Expand Up @@ -177,7 +180,7 @@ describe('run', () => {
firefoxProfile: runnerParams.profilePath,
args: runnerParams.args,
},
expectedRunnerParams,
expectedRunnerParams
);
assert.equal(runnerParams.extensions.length, 1);
assert.equal(runnerParams.extensions[0].sourceDir, cmd.argv.sourceDir);
Expand All @@ -195,15 +198,15 @@ describe('run', () => {
firefoxApp: runnerParams.firefoxApp,
firefoxClient: runnerParams.firefoxClient,
},
{ firefoxApp, firefoxClient },
{ firefoxApp, firefoxClient }
);
});

it('throws if watchFile is not an array', async () => {
const cmd = await prepareRun();
await assert.isRejected(
cmd.run({ noReload: false, watchFile: 'invalid-value.txt' }),
/Unexpected watchFile type/,
/Unexpected watchFile type/
);
});

Expand Down Expand Up @@ -313,7 +316,7 @@ describe('run', () => {
assert.equal(
chromiumBinary,
fakeChromiumBinary,
'Got the expected chromiumBinary option',
'Got the expected chromiumBinary option'
);
});

Expand All @@ -333,7 +336,7 @@ describe('run', () => {
assert.equal(
chromiumProfile,
fakeChromiumProfile,
'Got the expected chromiumProfile option',
'Got the expected chromiumProfile option'
);
});

Expand Down Expand Up @@ -394,15 +397,15 @@ describe('run', () => {
assert.equal(
chromiumProfile,
fakeProfile,
'Got the expected chromiumProfile option',
'Got the expected chromiumProfile option'
);
} else {
sinon.assert.calledOnce(desktopRunnerStub);
const firefoxProfile = desktopRunnerStub.firstCall.args[0].profilePath;
assert.equal(
firefoxProfile,
fakeProfile,
'Got the expected firefoxProfile option',
'Got the expected firefoxProfile option'
);
}
}
Expand Down Expand Up @@ -440,7 +443,7 @@ describe('run', () => {
await assert.isRejected(promise, cmd.errors.UsageError);
await assert.isRejected(
promise,
/requires --firefox-profile or --chromium-profile/,
/requires --firefox-profile or --chromium-profile/
);
});
});
Expand Down
Loading

0 comments on commit 5f01fe7

Please sign in to comment.