install.fairie/dotfiles/.vim/plugged/coc.nvim/esbuild.js
Git E2E Dev Test Username 6c3e92e48a git subrepo clone https://github.com/neoclide/coc.nvim.git ./dotfiles/.vim/plugged/coc.nvim
subrepo:
  subdir:   "dotfiles/.vim/plugged/coc.nvim"
  merged:   "7ca7cb915"
upstream:
  origin:   "https://github.com/neoclide/coc.nvim.git"
  branch:   "master"
  commit:   "7ca7cb915"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
2022-10-18 10:37:23 -04:00

66 lines
1.7 KiB
JavaScript

const cp = require('child_process')
const fs = require('fs')
const path = require('path')
let revision = 'master'
if (process.env.NODE_ENV !== 'development') {
try {
let res = cp.execSync(`git log -1 --date=iso --pretty=format:'"%h","%ad"'`, {encoding: 'utf8'})
revision = res.replaceAll('"', '').replace(',', ' ')
} catch (e) {
// ignore
}
}
let envPlugin = {
name: 'env',
setup(build) {
build.onResolve({filter: /\/appenders$/}, args => {
let fullpath = path.join(args.resolveDir, args.path)
return {
path: path.relative(__dirname, fullpath).replace(/\\/g, '/'),
namespace: 'env-ns'
}
})
build.onLoad({filter: /^node_modules\/log4js\/lib\/appenders$/, namespace: 'env-ns'}, args => {
let content = fs.readFileSync(path.join(args.path, 'index.js'), 'utf8')
return {
contents: content.replace(/require\.main/g, '""'),
resolveDir: args.path
}
})
}
}
async function start(watch) {
await require('esbuild').build({
entryPoints: ['src/main.ts'],
bundle: true,
watch,
minify: process.env.NODE_ENV === 'production',
sourcemap: process.env.NODE_ENV === 'development',
define: {REVISION: '"' + revision + '"', ESBUILD: 'true', 'global.__TEST__': false},
mainFields: ['module', 'main'],
platform: 'node',
target: 'node14.14',
outfile: 'build/index.js',
plugins: [envPlugin]
})
}
let watch = false
if (process.argv.includes('--watch')) {
console.log('watching...')
watch = {
onRebuild(error) {
if (error) {
console.error('watch build failed:', error)
} else {
console.log('watch build succeeded')
}
},
}
}
start(watch).catch(e => {
console.error(e)
})