Skip to content
This repository was archived by the owner on Jun 15, 2025. It is now read-only.
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