Commit d0a38d8
Changed files (3)
test.mjs
@@ -73,9 +73,9 @@ import {strict as assert} from 'assert'
}
{
- const versionModule = require('./version.js')
- console.log('require("./version.js") ->', versionModule)
- assert(typeof versionModule.version === 'string')
+ const {name, version} = require('./package.json')
+ assert(typeof name === 'string')
+ console.log(chalk.black.bgYellowBright(` ${name} version is ${version} `))
}
-console.log(chalk.green('🍺 Success!'))
+console.log(chalk.greenBright(' 🍺 Success!'))
version.js
@@ -1,15 +0,0 @@
-// Copyright 2021 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-module.exports.version = require('./package.json').version
zx.mjs
@@ -21,7 +21,6 @@ import { createRequire } from 'module'
import url from 'url'
import {v4 as uuid} from 'uuid'
import {$, cd, question, fetch, chalk, sleep, ProcessOutput} from './index.mjs'
-import {version} from './version.js'
Object.assign(global, {
$,
@@ -38,7 +37,7 @@ try {
let firstArg = process.argv[2]
if (['-v', '-V', '--version'].includes(firstArg)) {
- console.log(`zx version ${version}`)
+ console.log(`zx version ${createRequire(import.meta.url)('./package.json').version}`)
process.exit(0)
}