Skip to content

Commit 420b2e8

Browse files
committed
build: move from cjs to mjs
1 parent 6e247f9 commit 420b2e8

File tree

8 files changed

+365
-1269
lines changed

8 files changed

+365
-1269
lines changed

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"node": true
109109
},
110110
"parserOptions": {
111-
"sourceType": "script"
111+
"sourceType": "module"
112112
},
113113
"rules": {
114114
"no-console": "off",
@@ -124,4 +124,4 @@
124124
}
125125
}
126126
]
127-
}
127+
}

build/change-version.js renamed to build/change-version.mjs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
88
*/
99

10-
'use strict'
11-
12-
const fs = require('node:fs').promises
13-
const path = require('node:path')
14-
const globby = require('globby')
10+
import fs from 'node:fs/promises'
11+
import path from 'node:path'
12+
import globby from 'globby'
1513

1614
const VERBOSE = process.argv.includes('--verbose')
1715
const DRY_RUN = process.argv.includes('--dry') || process.argv.includes('--dry-run')

build/postcss.config.js renamed to build/postcss.config.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
'use strict'
2-
3-
module.exports = ctx => ({
4-
map: ctx.file.dirname.includes('examples') ?
1+
export default context => ({
2+
map: context.file.dirname.includes('examples') ?
53
false :
64
{
75
inline: false,

build/postinstall.js renamed to build/postinstall.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env node
2-
'use strict'
32

43
const main = () => {
54
if (

build/pug.js renamed to build/pug.mjs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#!/usr/bin/env node
2-
'use strict'
32

4-
const fs = require('node:fs').promises
5-
const path = require('node:path')
6-
const { mkdirp } = require('mkdirp')
7-
const pug = require('pug')
3+
import fs from 'node:fs/promises'
4+
import path from 'node:path'
5+
import { fileURLToPath } from 'node:url'
6+
import globby from 'globby'
7+
import pug from 'pug'
8+
import { mkdirp } from 'mkdirp'
89

9-
const { basename, dirname, resolve, sep } = path
10-
11-
const globby = require('globby')
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1211

13-
// These are the filetypes we only care about replacing the version
1412
const GLOB = [
1513
'**/*.pug'
1614
]
@@ -21,6 +19,8 @@ const GLOBBY_OPTIONS = {
2119
cwd: path.join(__dirname, '..', SRC)
2220
}
2321

22+
const { basename, dirname, resolve, sep } = path
23+
2424
const base = levels => {
2525
let path = './'
2626
while (levels > 0) {
@@ -44,7 +44,6 @@ const compile = (filename, basedir) => {
4444
return html
4545
}
4646

47-
// Build html files
4847
const compilePugToHtml = (file, dest) => {
4948
const dir = dirname(file)
5049
const filename = basename(file).replace('.pug', '.html')
@@ -62,25 +61,15 @@ const compilePugToHtml = (file, dest) => {
6261
})
6362
}
6463

65-
const args = require('minimist')(process.argv.slice(2))
66-
67-
async function main(args) {
68-
const { dest } = args
69-
70-
if (!dest) {
71-
console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]')
72-
console.error('Got arguments:', args)
73-
process.exit(1)
74-
}
75-
64+
async function main() {
7665
try {
7766
const files = await globby(GLOB, GLOBBY_OPTIONS)
7867

79-
await Promise.all(files.map(file => compilePugToHtml(file, dest)))
68+
await Promise.all(files.map(file => compilePugToHtml(file, 'src/views/')))
8069
} catch (error) {
8170
console.error(error)
8271
process.exit(1)
8372
}
8473
}
8574

86-
main(args)
75+
main()

build/vendors.js renamed to build/vendors.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#!/usr/bin/env node
22

3-
'use strict'
3+
import fs from 'node:fs'
4+
import path from 'node:path'
5+
import injectVendors from '@coreui/vendors-injector'
46

5-
const fs = require('node:fs')
6-
const path = require('node:path')
7-
const injector = require('@coreui/vendors-injector')
7+
const DIST = 'dist/'
88

99
const { extname, join } = path
1010

11-
const DIST = 'dist/'
12-
1311
const walkSync = (dir, filelist = []) => {
1412
for (const file of fs.readdirSync(dir)) {
1513
filelist = fs.statSync(join(dir, file)).isDirectory() ? walkSync(join(dir, file), filelist) : filelist.concat(join(dir, file))
@@ -22,7 +20,7 @@ const main = () => {
2220
const filenames = walkSync(DIST)
2321
for (const filename of filenames) {
2422
if (extname(filename) === '.html') {
25-
injector.toFile(filename)
23+
injectVendors.toFile(filename)
2624
}
2725
}
2826
}

0 commit comments

Comments
 (0)