-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent the root from being deleted during the build
- Loading branch information
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { expect } from 'chai'; | ||
import { loadFixture } from './test-utils.js'; | ||
import * as fs from 'fs'; | ||
|
||
describe('outDir set to project root', async () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
/** @type {Error | undefined} */ | ||
let error; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ root: './fixtures/dont-delete-me/' }); | ||
try { | ||
await fixture.build(); | ||
} catch(err) { | ||
error = err; | ||
} | ||
}); | ||
|
||
it('Throws an error when you attempt to build', async () => { | ||
expect(error).to.be.an.instanceOf(Error); | ||
expect(error.message).to.match(/outDir cannot be the root folder/); | ||
}); | ||
|
||
it('Files have not been deleted', async () => { | ||
const expectedFiles = [ | ||
'package.json', | ||
'astro.config.mjs', | ||
'src/pages/index.astro' | ||
]; | ||
|
||
for(const rel of expectedFiles) { | ||
const root = new URL('./fixtures/dont-delete-me/', import.meta.url); | ||
const url = new URL('./' + rel, root); | ||
const stats = await fs.promises.stat(url); | ||
expect(stats).to.not.be.undefined; | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { defineConfig } from 'astro/config'; | ||
|
||
export default defineConfig({ | ||
outDir: './' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@test/dont-delete-me", | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/dont-delete-me/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<head> | ||
<title>Testing</title> | ||
</head> | ||
<body> | ||
|
||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.