Skip to content

Commit

Permalink
refactor: use esm
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jan 22, 2024
1 parent 8a57b85 commit 5dc857c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@
"git-authors-cli": "latest",
"git-dirty": "latest",
"github-generate-release": "latest",
"got": "11",
"got": "latest",
"listr": "latest",
"lodash": "latest",
"meow": "9",
"nano-staged": "latest",
"p-all": "3",
"picocolors": "latest",
"prettier": "latest",
"pretty-bytes": "5",
"pretty-ms": "7",
"pretty-bytes": "latest",
"pretty-ms": "latest",
"puppeteer": "latest",
"simple-git-hooks": "latest",
"standard": "latest",
"standard-markdown": "latest",
"standard-version": "latest",
"unique-random-array": "2"
"unique-random-array": "latest"
},
"engines": {
"node": ">= 18"
Expand All @@ -67,11 +67,11 @@
"dist"
],
"scripts": {
"build": "node scripts/build.js dist https://cdn.microlink.io/",
"build": "node scripts/build.mjs dist https://cdn.microlink.io/",
"clean": "rm -rf node_modules",
"dev": "watchexec --exts js -- node scripts/build.js dist https://cdn.microlink.io/",
"dev": "watchexec --exts js -- node scripts/build.mjs dist https://cdn.microlink.io/",
"lint": "standard-markdown README.md && standard",
"postbuild": "node scripts/postbuild.js",
"postbuild": "node scripts/postbuild.mjs",
"postrelease": "npm run release:tags && npm run release:github",
"prerelease": "git-dirty && npm run update:check && npm test && git-authors-cli",
"pretest": "npm run lint",
Expand Down
10 changes: 5 additions & 5 deletions scripts/build.js → scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

const { statSync, readdirSync } = require('fs')
const { writeFile } = require('fs/promises')
const prettyBytes = require('pretty-bytes')
const prettier = require('prettier')
const path = require('path')
import { statSync, readdirSync } from 'fs'
import { writeFile } from 'fs/promises'
import prettyBytes from 'pretty-bytes'
import prettier from 'prettier'
import path from 'path'

const IGNORE_FILES = ['.DS_Store', 'data', 'index.html']
const URLS = []
Expand Down
26 changes: 13 additions & 13 deletions scripts/postbuild.js → scripts/postbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict'

const prettyMs = require('pretty-ms')

const timeSpan = require('@kikobeats/time-span')({ format: prettyMs })
import prettyMs from 'pretty-ms'
import createTimeSpan from '@kikobeats/time-span'

const URLS = require('../urls.json')

const timeSpan = createTimeSpan({ format: prettyMs })

const {
CLOUDFLARE_MAX_FILES = 30,
CLOUDFLARE_AUTH_EMAIL,
Expand Down Expand Up @@ -35,13 +36,12 @@ const cloudflare = require('got').extend({

const total = timeSpan()

;(async () => {
for (const files of chunks(URLS, CLOUDFLARE_MAX_FILES)) {
await cloudflare('purge_cache', {
method: 'POST',
body: JSON.stringify({ files })
})
process.stdout.write(' ' + total() + ' ')
}
process.stdout.write('✨\n')
})()
for (const files of chunks(URLS, CLOUDFLARE_MAX_FILES)) {
await cloudflare('purge_cache', {
method: 'POST',
body: JSON.stringify({ files })
})
process.stdout.write(' ' + total() + ' ')
}

process.stdout.write('✨\n')

0 comments on commit 5dc857c

Please sign in to comment.