Skip to content

Commit

Permalink
add CSA version to the output
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy committed Jan 8, 2024
1 parent 47cf955 commit e9b31d5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import path from 'node:path'
import { exec as ecp, spawn } from 'node:child_process'
import os from 'node:os'

const exec = util.promisify(ecp)
const __dirname = path.dirname(import.meta.url).replace(`file://${os.platform() === 'win32' ? '/' : ''}`, '')

const csaVersion = JSON.parse(await fs.readFile(path.join(__dirname, './package.json'))).version

const exec = util.promisify(ecp)
const DEFAULT_TEMPLATE = 'vanilla'

async function copyFileOrFolder (source, target) {
Expand Down Expand Up @@ -36,6 +39,7 @@ const cp = async (a, b) => copyFileOrFolder(
)

async function help (templateNames) {
console.log(`create-socket-app v${csaVersion}`)
console.log(`usage: npm create socket-app [${templateNames.join(' | ')}]`)
}

Expand Down Expand Up @@ -79,7 +83,7 @@ async function main (argv) {

const templateNames = await fs.readdir(path.join(__dirname, 'templates'))

if (argv.find(s => s.includes('-h'))) {
if (argv.find(s => s.includes('-h')) || argv.find(s => s.includes('--help')) || argv.find(s => s.includes('-v')) || argv.find(s => s.includes('--version'))) {
return help(templateNames)
}

Expand Down

0 comments on commit e9b31d5

Please sign in to comment.