Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions configurations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"noUncheckedIndexedAccess": true,
"jsx": "react",
"paths": {
"@shopify/cli-kit": ["../packages/cli-kit/src/index"],
"@shopify/cli-kit/*": ["../packages/cli-kit/src/public/*"],
"@shopify/theme/*": ["../packages/theme/src/*"],
"@shopify/cli-kit/typing/*": ["../packages/cli-kit/src/typing/*"],
Expand Down
12 changes: 6 additions & 6 deletions docs/cli/testing-strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ pnpm test path/to/my.test.ts
If the subject under testing does a filesystem I/O operation, we recommend not stubbing that behavior instead of hitting the filesystem. Create a temporary directory whose lifecycle is tied to the lifecycle of the test:

```ts
import {file, path} from "@shopify/cli-kit"
import {exists, inTemporaryDirectory, writeFile} from "@shopify/cli-kit/node/fs"
import {joinPath} from "@shopify/cli-kit/node/path"

test("writes", async () => {
await file.inTemporaryDirectory(async (tmpDir: string) => {
await inTemporaryDirectory(async (tmpDir: string) => {
// Given
const outputPath = path.join(tmpDir, "output")
const outputPath = joinPath(tmpDir, "output")

// When
await file.write(outputPath, "content")
await writeFile(outputPath, "content")

// Then
const exists = await file.exists(outputPath)
expect(exists).toBe(true)
expect(await exists(outputPath)).toBe(true)
})
})
```
Expand Down
9 changes: 9 additions & 0 deletions packages/cli-kit/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {file, path} from './index.js'
import {describe, expect, test} from 'vitest'

describe('root exports', () => {
test('exposes documented filesystem and path helpers', () => {
expect(file.inTemporaryDirectory).toBeTypeOf('function')
expect(path.joinPath).toBeTypeOf('function')
})
})
2 changes: 2 additions & 0 deletions packages/cli-kit/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * as file from './public/node/fs.js'
export * as path from './public/node/path.js'
Loading