Skip to content

Commit 0206c4c

Browse files
authoredMay 26, 2022
fix: ts tests (#984)
Using `npm link` ends up deleting folders called "build" from the node_modules folder which is undesirable. Instead just create the `.bin` directory and symlink aegir into it for testing.
1 parent f18d914 commit 0206c4c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed
 

‎test/test.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import fs, { copy } from 'fs-extra'
55
import path, { join } from 'path'
66
import tempy from 'tempy'
77
import { fileURLToPath } from 'url'
8+
import os from 'os'
89

910
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1011

@@ -16,26 +17,34 @@ async function setUpProject (project) {
1617

1718
await copy(join(__dirname, 'fixtures', 'projects', project), projectDir)
1819
const nodeModulesPath = path.resolve(__dirname, '../node_modules')
20+
const projectNodeModulesPath = path.join(projectDir, 'node_modules')
21+
const aegirPath = path.resolve(__dirname, '..')
1922

2023
// simulate having installed aegir
2124
for (const entry of await fs.readdir(nodeModulesPath)) {
22-
if (entry === '.' || entry === '..') {
25+
if (entry === '.' || entry === '..' || entry === '.bin') {
2326
continue
2427
}
2528

2629
// symlink dep
27-
await fs.createSymlink(path.join(nodeModulesPath, entry), path.join(projectDir, 'node_modules', entry), 'dir')
30+
await fs.createSymlink(path.join(nodeModulesPath, entry), path.join(projectNodeModulesPath, entry), 'dir')
2831
}
2932

3033
// link aegir into project
31-
await execa('npm', ['link', path.resolve(__dirname, '..')], {
32-
cwd: projectDir
33-
})
34+
await fs.mkdir(path.join(projectNodeModulesPath, '.bin'))
35+
await fs.createSymlink(aegirPath, path.join(projectNodeModulesPath, 'aegir'), 'dir')
36+
await fs.createSymlink(path.join(aegirPath, 'src', 'index.js'), path.join(projectNodeModulesPath, '.bin', 'aegir'), 'file')
3437

3538
return projectDir
3639
}
3740

3841
describe('test', () => {
42+
if (os.platform() === 'win32') {
43+
describe.skip('Skipping tests on windows because symlinking works differently', () => {})
44+
45+
return
46+
}
47+
3948
describe('esm', function () {
4049
let projectDir = ''
4150

0 commit comments

Comments
 (0)
Please sign in to comment.