File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 6
6
// ╚═════╝╚══════╝╚═╝
7
7
8
8
import path from 'path'
9
+ import fs from 'fs'
9
10
import { ALL_TEMPLATES , DEFAULT_TEMPLATE , BROWSERS } from './fixtures/constants'
10
11
import {
11
12
extensionProgram ,
@@ -93,22 +94,26 @@ describe('extension build', () => {
93
94
`builds and zips the source files of an extension created via "$name" template` ,
94
95
async ( template ) => {
95
96
const extensionPath = path . join ( __dirname , 'fixtures' , template . name )
97
+ const outputPath = path . join (
98
+ __dirname ,
99
+ 'fixtures' ,
100
+ template . name ,
101
+ 'dist'
102
+ )
96
103
97
104
await extensionProgram ( `build ${ extensionPath } --zip-source` )
98
105
99
106
expect (
100
- distFileExists (
101
- template . name ,
102
- BROWSERS [ 0 ] ,
103
- `${ template . name } -1.0-source.zip`
107
+ fs . existsSync (
108
+ path . join ( outputPath , `${ template . name } -1.0-source.zip` )
104
109
)
105
110
) . toBeTruthy ( )
106
111
} ,
107
112
50000
108
113
)
109
114
110
115
it . each ( [ DEFAULT_TEMPLATE ] ) (
111
- `builds and zips the source files of an extension created via "$name" template with a custom output name using the --zip-filename flag` ,
116
+ `builds and zips the distribution files of an extension created via "$name" template with a custom output name using the --zip-filename flag` ,
112
117
async ( template ) => {
113
118
const extensionPath = path . join ( __dirname , 'fixtures' , template . name )
114
119
@@ -117,11 +122,7 @@ describe('extension build', () => {
117
122
)
118
123
119
124
expect (
120
- distFileExists (
121
- template . name ,
122
- BROWSERS [ 0 ] ,
123
- `${ template . name } -nice.zip`
124
- )
125
+ distFileExists ( template . name , BROWSERS [ 0 ] , `${ template . name } -nice.zip` )
125
126
) . toBeTruthy ( )
126
127
} ,
127
128
50000
Original file line number Diff line number Diff line change @@ -72,16 +72,19 @@ export default function generateZip(
72
72
{ browser = 'chrome' , ...options } : BuildOptions
73
73
) {
74
74
try {
75
- const outputDir = path . join ( projectDir , 'dist' , browser )
75
+ const distDir = path . join ( projectDir , 'dist' )
76
+ const outputDir = path . join ( distDir , browser )
76
77
// We collect data from the projectDir if the user wants to zip the source files.
77
78
const dataDir = options . zipSource ? projectDir : outputDir
78
79
const manifest : Record < string , string > = require (
79
80
path . join ( dataDir , 'manifest.json' )
80
81
)
81
82
const name = getPackageName ( manifest , options )
82
83
const ext = getExtensionExtension ( browser )
84
+ // Dist zips are stored in dist/[browser]/[name].zip
83
85
const distZipPath = path . join ( outputDir , `${ name } .${ ext } ` )
84
- const sourceZipPath = path . join ( outputDir , `${ name } -source.${ ext } ` )
86
+ // Source zips are stored in dist/[name]-source.zip
87
+ const sourceZipPath = path . join ( distDir , `${ name } -source.${ ext } ` )
85
88
const capitalizedBrowser = capitalizeBrowserName ( browser )
86
89
87
90
if ( options . zipSource ) {
You can’t perform that action at this time.
0 commit comments