Skip to content

Commit

Permalink
chore: separate building scripts for Chrome and Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemSBulgakov committed Jun 21, 2024
1 parent 2c8a090 commit 0c16c95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
"private": true,
"description": "Convenient tools for Moodle, InNoHassle and other services at Innopolis University.",
"scripts": {
"dev": "vite",
"build": "npm run build:chrome",
"dev": "BROWSER=chrome vite",
"dev:firefox": "BROWSER=firefox vite",
"build:chrome": "tsc && BROWSER=chrome vite build",
"build:firefox": "tsc && BROWSER=firefox vite build",
"zip:chrome": "npm run build:chrome && node scripts/zip.js",
"zip:firefox": "npm run build:firefox && node scripts/zip.js",
"preview": "vite preview",
"zip:chrome": "npm run build:chrome && BROWSER=chrome node scripts/zip.js",
"zip:firefox": "npm run build:firefox && BROWSER=firefox node scripts/zip.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"deps": "taze -wIr",
Expand Down
14 changes: 12 additions & 2 deletions scripts/zip.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { createRequire } from 'node:module'
import process from 'node:process'
import gulp from 'gulp'
import zip from 'gulp-zip'

const require = createRequire(import.meta.url)
const manifest = require('../build/manifest.json')

const postfix = process.argv[2] ? `-${process.argv[2]}` : ''

const isFirefox = process.env.BROWSER === 'firefox'
const browserPostfix = isFirefox ? '-firefox' : '-chrome'

const dashedName = manifest.name.replaceAll(' ', '-')
const fileName = `${dashedName}-${manifest.version}${postfix}${browserPostfix}.zip`

gulp
.src('build/**')
.pipe(zip(`${manifest.name.replaceAll(' ', '-')}-${manifest.version}.zip`))
.pipe(zip(fileName))
.pipe(gulp.dest('package'))
console.log(`${manifest.name.replaceAll(' ', '-')}-${manifest.version}.zip`)

console.log(fileName)

0 comments on commit 0c16c95

Please # to comment.