Skip to content

Commit

Permalink
Merge pull request #315 from nobkd/fix/create
Browse files Browse the repository at this point in the history
test: don't open link on test, basic create cli testing
  • Loading branch information
tipiirai authored Aug 14, 2024
2 parents 78a433e + 423d74b commit e2119f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/nuekit/src/create.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { exec, execSync } from 'node:child_process'
import { execSync } from 'node:child_process'
import { promises as fs, existsSync } from 'node:fs'
import { join } from 'node:path'

import { openUrl } from './util.js'
import { createKit } from './nuekit.js'

async function serve(root) {
async function serve(root, debug) {
const nue = await createKit({ root })
const terminate = await nue.serve()

// open welcome page
exec(`${openUrl} http://localhost:${nue.port}/welcome/`)
if (!debug) execSync(`${openUrl} http://localhost:${nue.port}/welcome/`)
return terminate
}

Expand Down Expand Up @@ -49,5 +49,5 @@ export async function create({ root, name = 'simple-blog' }) {
await fs.rm(archive_name)

// serve
return await serve(root)
return await serve(root, debug)
}
11 changes: 7 additions & 4 deletions packages/nuekit/test/misc.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { match } from '../src/browser/app-router.js'

import { parsePathParts, sortCSS } from '../src/util.js'
import { parsePathParts } from '../src/util.js'
import { lightningCSS } from '../src/builder.js'
import { create } from '../src/create.js'
import { getArgs } from '../src/cli.js'
Expand Down Expand Up @@ -58,8 +58,11 @@ test('path parts', () => {
expect(parts.slug).toBe('semantic-css.html')
})


test('create', async () => {
const terminate = await create({ root, name: 'test' })
terminate()
const terminate = await create({ root, name: 'test' })
terminate()

const contents = await fs.readdir(root)
expect(contents).toContain('index.md') // should be unpacked to correct dir
expect(contents).toContain('.dist') // should be built
})

0 comments on commit e2119f3

Please sign in to comment.