Skip to content

Commit 6aa770f

Browse files
committed
Fix clean function
1 parent aee98a3 commit 6aa770f

File tree

16 files changed

+87
-84
lines changed

16 files changed

+87
-84
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Code of Conduct
32

43
## Our Pledge
@@ -18,23 +17,23 @@ diverse, inclusive, and healthy community.
1817
Examples of behavior that contributes to a positive environment for our
1918
community include:
2019

21-
* Demonstrating empathy and kindness toward other people
22-
* Being respectful of differing opinions, viewpoints, and experiences
23-
* Giving and gracefully accepting constructive feedback
24-
* Accepting responsibility and apologizing to those affected by our mistakes,
20+
- Demonstrating empathy and kindness toward other people
21+
- Being respectful of differing opinions, viewpoints, and experiences
22+
- Giving and gracefully accepting constructive feedback
23+
- Accepting responsibility and apologizing to those affected by our mistakes,
2524
and learning from the experience
26-
* Focusing on what is best not just for us as individuals, but for the overall
25+
- Focusing on what is best not just for us as individuals, but for the overall
2726
community
2827

2928
Examples of unacceptable behavior include:
3029

31-
* The use of sexualized language or imagery, and sexual attention or advances of
30+
- The use of sexualized language or imagery, and sexual attention or advances of
3231
any kind
33-
* Trolling, insulting or derogatory comments, and personal or political attacks
34-
* Public or private harassment
35-
* Publishing others' private information, such as a physical or email address,
32+
- Trolling, insulting or derogatory comments, and personal or political attacks
33+
- Public or private harassment
34+
- Publishing others' private information, such as a physical or email address,
3635
without their explicit permission
37-
* Other conduct which could reasonably be considered inappropriate in a
36+
- Other conduct which could reasonably be considered inappropriate in a
3837
professional setting
3938

4039
## Enforcement Responsibilities

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[npm-version-image]: https://img.shields.io/npm/v/extension.svg?color=0971fe
22
[npm-version-url]: https://www.npmjs.com/package/extension
3-
[downloads-image]: https://img.shields.io/npm/dm/extension.svg
3+
[downloads-image]: https://img.shields.io/npm/dm/extension.svg?color=2ecc40
44
[downloads-url]: https://npmjs.org/package/extension
5-
[action-image]: https://github.com/extension-js/extension.js/actions/workflows/ci.yml/badge.svg?branch=main
5+
[action-image]: https://github.com/extension-js/extension.js/actions/workflows/ci.yml/badge.svg?branch=main&color=2ecc40
66
[action-url]: https://github.com/extension-js/extension.js/actions
7-
[coverage-image]: https://img.shields.io/codecov/c/github/extension-js/extension.js
7+
[coverage-image]: https://img.shields.io/codecov/c/github/extension-js/extension.js?color=2ecc40
88
[coverage-url]: https://codecov.io/github/extension-js/extension.js
9-
[discord-image]: https://img.shields.io/discord/1253608412890271755?label=Discord&logo=discord&style=flat
9+
[discord-image]: https://img.shields.io/discord/1253608412890271755?label=Discord&logo=discord&style=flat&color=2ecc40
1010
[discord-url]: https://discord.gg/v9h2RgeTSN
11-
[snyk-image]: https://snyk.io/test/github/extension-js/extension/badge.svg
11+
[snyk-image]: https://snyk.io/test/github/extension-js/extension/badge.svg?color=2ecc40
1212
[snyk-url]: https://snyk.io/test/github/extension-js/extension
1313

1414
> The cross-browser extension framework

programs/cli/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[npm-version-image]: https://img.shields.io/npm/v/extension.svg?color=0971fe
22
[npm-version-url]: https://www.npmjs.com/package/extension
3-
[downloads-image]: https://img.shields.io/npm/dm/extension.svg
3+
[downloads-image]: https://img.shields.io/npm/dm/extension.svg?color=2ecc40
44
[downloads-url]: https://npmjs.org/package/extension
5-
[action-image]: https://github.com/extension-js/extension.js/actions/workflows/ci.yml/badge.svg?branch=main
5+
[action-image]: https://github.com/extension-js/extension.js/actions/workflows/ci.yml/badge.svg?branch=main&color=2ecc40
66
[action-url]: https://github.com/extension-js/extension.js/actions
7-
[coverage-image]: https://img.shields.io/codecov/c/github/extension-js/extension.js
7+
[coverage-image]: https://img.shields.io/codecov/c/github/extension-js/extension.js?color=2ecc40
88
[coverage-url]: https://codecov.io/github/extension-js/extension.js
9-
[discord-image]: https://img.shields.io/discord/1253608412890271755?label=Discord&logo=discord&style=flat
9+
[discord-image]: https://img.shields.io/discord/1253608412890271755?label=Discord&logo=discord&style=flat&color=2ecc40
1010
[discord-url]: https://discord.gg/v9h2RgeTSN
11-
[snyk-image]: https://snyk.io/test/github/extension-js/extension/badge.svg
11+
[snyk-image]: https://snyk.io/test/github/extension-js/extension/badge.svg?color=2ecc40
1212
[snyk-url]: https://snyk.io/test/github/extension-js/extension
1313

1414
> The cross-browser extension framework

programs/develop/commands/build.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export async function extensionBuild(
4040
browser,
4141
mode: 'production',
4242
output: {
43-
clean: true
43+
clean: true,
44+
path: path.join(projectPath, 'dist', browser)
4445
}
4546
})
4647

programs/develop/commands/commands-lib/config-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface BuildOptions {
5353

5454
export interface PreviewOptions extends BrowserOptionsBase {
5555
mode: 'production'
56+
outputPath?: string
5657
chromiumBinary?: ChromiumOptions['chromiumBinary']
5758
geckoBinary?: GeckoOptions['geckoBinary']
5859
}

programs/develop/commands/commands-lib/get-project-path.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as path from 'path'
2+
import * as fs from 'fs'
23
import goGitIt from 'go-git-it'
34
import * as messages from './messages'
45
import {downloadAndExtractZip} from './extract-from-zip'

programs/develop/commands/commands-lib/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export function writingTypeDefinitionsError(error: any) {
236236

237237
export function downloadingText(url: string) {
238238
return (
239-
`${getLoggingPrefix('info')} Downloading extension...\n` +
239+
`${getLoggingPrefix('info')} Downloading browser extension...\n` +
240240
`${chalk.gray('URL')} ${chalk.underline(url)}`
241241
)
242242
}

programs/develop/commands/preview.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import * as path from 'path'
1010
import {rspack, type Configuration} from '@rspack/core'
1111
import {merge} from 'webpack-merge'
1212
import webpackConfig from '../webpack/webpack-config'
13-
import {getProjectPath} from './commands-lib/get-project-path'
13+
import {
14+
getProjectPath,
15+
} from './commands-lib/get-project-path'
1416
import * as messages from './commands-lib/messages'
1517
import {loadCustomWebpackConfig} from './commands-lib/get-extension-config'
1618
import {PreviewOptions} from './commands-lib/config-types'
@@ -20,6 +22,19 @@ export async function extensionPreview(
2022
previewOptions: PreviewOptions
2123
) {
2224
const projectPath = await getProjectPath(pathOrRemoteUrl)
25+
const distPath = path.join(projectPath, 'dist', previewOptions.browser)
26+
27+
// Output path defaults to extensionPreview config.
28+
// The start command will use the build directory.
29+
// The preview command will use the build directory if it exists,
30+
// otherwise it will use the project path.
31+
// This is useful for remote packages that don't have a build directory.
32+
// but are ready for manual browser testing.
33+
const outputPath = previewOptions.outputPath
34+
? previewOptions.outputPath
35+
: fs.existsSync(distPath)
36+
? distPath
37+
: projectPath
2338

2439
if (
2540
!pathOrRemoteUrl?.startsWith('http') &&
@@ -30,7 +45,7 @@ export async function extensionPreview(
3045
)
3146
process.exit(1)
3247
}
33-
48+
3449
try {
3550
const browser = previewOptions.browser || 'chrome'
3651
const baseConfig: Configuration = webpackConfig(projectPath, {
@@ -43,7 +58,8 @@ export async function extensionPreview(
4358
// Preview needs a build before running so
4459
// we don't want to clean the output directory.
4560
output: {
46-
clean: false
61+
clean: false,
62+
path: outputPath
4763
}
4864
})
4965

@@ -66,9 +82,7 @@ export async function extensionPreview(
6682
}
6783

6884
if (!stats?.hasErrors()) {
69-
console.log(
70-
messages.runningInProduction(path.join(projectPath, 'dist', browser))
71-
)
85+
console.log(messages.runningInProduction(projectPath))
7286
} else {
7387
console.log(stats.toString({colors: true}))
7488
process.exit(1)

programs/develop/commands/start.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ export async function extensionStart(
3939

4040
await extensionPreview(pathOrRemoteUrl, {
4141
...startOptions,
42-
browser
42+
browser,
43+
// Starts preview the extension from the build directory
44+
outputPath: path.join(projectPath, 'dist', browser)
4345
})
4446
} catch (error) {
4547
if (process.env.EXTENSION_ENV === 'development') {

programs/develop/webpack/dev-server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ export async function devServer(projectPath: string, devOptions: DevOptions) {
6666
...browserConfig,
6767
mode: 'development',
6868
output: {
69-
clean: false
69+
clean: false,
70+
path: path.join(projectPath, 'dist', devOptions.browser)
7071
}
7172
})
7273

0 commit comments

Comments
 (0)