Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CSA version to the output #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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