|
3 | 3 |
|
4 | 4 | const { expect } = require('../utils/chai') |
5 | 5 | const execa = require('execa') |
6 | | -const process = require('process') |
7 | 6 | const { copy, existsSync } = require('fs-extra') |
8 | | -const { join } = require('path') |
| 7 | +const fs = require('fs') |
| 8 | +const os = require('os') |
| 9 | +const { join, normalize } = require('path') |
9 | 10 | const bin = require.resolve('../') |
10 | | -const tempy = require('tempy') |
11 | 11 |
|
12 | 12 | describe('build', () => { |
13 | | - if (process.platform !== 'win32') { |
14 | | - describe('esm', () => { |
15 | | - let projectDir = '' |
| 13 | + describe('esm', () => { |
| 14 | + let projectDir = '' |
16 | 15 |
|
17 | | - before(async () => { |
18 | | - projectDir = tempy.directory() |
| 16 | + before(async () => { |
| 17 | + projectDir = `${os.tmpdir()}/${Date.now()}` |
19 | 18 |
|
20 | | - await copy(join(__dirname, 'fixtures', 'esm', 'an-esm-project'), projectDir) |
21 | | - }) |
| 19 | + await copy(join(__dirname, 'fixtures', 'esm', 'an-esm-project'), projectDir) |
| 20 | + }) |
| 21 | + |
| 22 | + after(async () => { |
| 23 | + await fs.promises.rm(projectDir, { recursive: true }) |
| 24 | + }) |
| 25 | + |
| 26 | + it('should build an esm project', async function () { |
| 27 | + this.timeout(20 * 1000) // slow ci is slow |
22 | 28 |
|
23 | | - it('should build an esm project', async function () { |
24 | | - this.timeout(20 * 1000) // slow ci is slow |
| 29 | + // eslint-disable-next-line |
| 30 | + console.log('dir', projectDir) |
| 31 | + // eslint-disable-next-line |
| 32 | + console.log('bin', bin, ) |
25 | 33 |
|
26 | | - await execa(bin, ['build'], { |
27 | | - cwd: projectDir |
| 34 | + try { |
| 35 | + await execa(normalize(`${bin}`), ['build'], { |
| 36 | + cwd: normalize(projectDir), |
| 37 | + windowsVerbatimArguments: true |
28 | 38 | }) |
| 39 | + } catch (err) { |
| 40 | + // eslint-disable-next-line |
| 41 | + console.log('err', err) |
| 42 | + } |
29 | 43 |
|
30 | | - expect(existsSync(join(projectDir, 'dist', 'esm'))).to.be.true() |
31 | | - expect(existsSync(join(projectDir, 'dist', 'cjs'))).to.be.true() |
| 44 | + expect(existsSync(join(projectDir, 'dist', 'esm'))).to.be.true() |
| 45 | + expect(existsSync(join(projectDir, 'dist', 'cjs'))).to.be.true() |
32 | 46 |
|
33 | | - const module = require(join(projectDir, 'dist')) |
| 47 | + const module = require(join(projectDir, 'dist')) |
34 | 48 |
|
35 | | - expect(module).to.have.property('useHerp').that.is.a('function') |
36 | | - expect(module).to.have.property('useDerp').that.is.a('function') |
37 | | - }) |
| 49 | + expect(module).to.have.property('useHerp').that.is.a('function') |
| 50 | + expect(module).to.have.property('useDerp').that.is.a('function') |
38 | 51 | }) |
39 | | - } |
| 52 | + }) |
40 | 53 | }) |
0 commit comments