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
14 changes: 13 additions & 1 deletion packages/create/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export function createDefaultEnvironment(): Environment {

appendFile: async (path: string, contents: string) => {
await mkdir(dirname(path), { recursive: true })
if (existsSync(path)) {
const existing = await readFile(path, 'utf-8')
if (existing.length > 0) {
await appendFile(path, existing.endsWith('\n') ? '\n' : '\n\n')
}
}
return appendFile(path, contents)
},
copyFile: async (from: string, to: string) => {
Expand Down Expand Up @@ -127,7 +133,13 @@ export function createMemoryEnvironment(returnPathsRelativeTo: string = '') {

environment.appendFile = async (path: string, contents: string) => {
fs.mkdirSync(dirname(path), { recursive: true })
await fs.appendFileSync(path, contents)
if (fs.existsSync(path)) {
const existing = fs.readFileSync(path, 'utf-8') as string
if (existing.length > 0) {
fs.appendFileSync(path, existing.endsWith('\n') ? '\n' : '\n\n')
}
}
fs.appendFileSync(path, contents)
}
environment.copyFile = async (from: string, to: string) => {
fs.mkdirSync(dirname(to), { recursive: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mcp-todos.json
mcp-todos.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ VITE_SENTRY_ORG=
VITE_SENTRY_PROJECT=

# Your Sentry authentication token (from your Sentry account)
SENTRY_AUTH_TOKEN=
SENTRY_AUTH_TOKEN=
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Strapi configuration
VITE_STRAPI_URL="http://localhost:1337"
VITE_STRAPI_URL="http://localhost:1337"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Strapi configuration
VITE_STRAPI_URL="http://localhost:1337/api"
VITE_STRAPI_URL="http://localhost:1337/api"
2 changes: 1 addition & 1 deletion packages/create/tests/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('createDefaultEnvironment', () => {
await environment.copyFile('/test.txt', '/test2.txt')
environment.finishRun()

expect(fs.readFileSync('/test.txt', 'utf8')).toEqual('testtest2')
expect(fs.readFileSync('/test.txt', 'utf8')).toEqual('test\n\ntest2')
})

it('should allow deletes', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/create/tests/filename-processing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('Filename Processing - Prefix Stripping', () => {

// File should be created with prefix stripped and content appended
expect(output.files['/test/.env']).toBeDefined()
expect(output.files['/test/.env']).toEqual('BASE_VAR=value\n\nDATABASE_URL=postgresql://localhost:5432/mydb\n')
expect(output.files['/test/.env']).toEqual('BASE_VAR=value\n\n\nDATABASE_URL=postgresql://localhost:5432/mydb\n')
})

it('should handle files without prefixes normally', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/create/tests/template-file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('createTemplateFile', () => {
await templateFile('test.txt.append', 'Line 2\n')
environment.finishRun()

expect(output.files['/test/test.txt']).toEqual('Line 1\nLine 2\n')
expect(output.files['/test/test.txt']).toEqual('Line 1\n\nLine 2\n')
})

it('should handle enabled add-ons', async () => {
Expand Down
Loading