Skip to content

Commit

Permalink
fix: move linaria cache directory into node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
test123456789012345 committed Feb 29, 2020
1 parent aa9b0cf commit 2c1e1e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@dword-design/base": "^6.0.15",
"@dword-design/puppeteer": "^1.0.1",
"execa": "^4.0.0",
"fs-extra": "^8.1.0",
"get-package-name": "^1.1.0",
"output-files": "^1.1.15",
"port-ready": "^0.1.0",
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { omit } from '@dword-design/functions'
import P from 'path'

export default function () {
this.extendBuild(config => {
Expand All @@ -10,6 +11,7 @@ export default function () {
options: {
sourceMap: this.options.dev,
babelOptions: this.options.build.babel |> omit('cacheDirectory'),
cacheDirectory: P.join('node_modules', '.cache', 'linaria'),
},
})
})
Expand Down
18 changes: 11 additions & 7 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import kill from 'tree-kill-promise'
import { endent } from '@dword-design/functions'
import execa from 'execa'
import getPackageName from 'get-package-name'
import { exists } from 'fs-extra'
import P from 'path'

let browser
let page
Expand All @@ -16,7 +18,7 @@ export default {
page = await browser.newPage()
},
after: () => browser.close(),
css: () => withLocalTmpDir(async () => {
valid: () => withLocalTmpDir(async () => {
await outputFiles({
'nuxt.config.js': endent`
export default {
Expand All @@ -38,13 +40,15 @@ export default {
}
`,
})
await execa('nuxt', ['build'])
const childProcess = execa('nuxt', ['start'])
await execa.command('nuxt build')
const childProcess = execa.command('nuxt start')
try {
await portReady(3000)
await page.goto('http://localhost:3000')
const backgroundColor = await page.$eval('.foo', el => getComputedStyle(el).backgroundColor)
expect(backgroundColor).toMatch('rgb(255, 0, 0)')
expect(await exists('.linaria-cache')).toBeFalsy()
expect(await exists(P.join('node_modules', '.cache', 'linaria', 'pages', 'index.linaria.css'))).toBeTruthy()
} finally {
await kill(childProcess.pid)
}
Expand All @@ -71,8 +75,8 @@ export default {
}
`,
})
await execa('nuxt', ['build'])
const childProcess = execa('nuxt', ['start'])
await execa.command('nuxt build')
const childProcess = execa.command('nuxt start')
try {
await portReady(3000)
await page.goto('http://localhost:3000')
Expand Down Expand Up @@ -108,8 +112,8 @@ export default {
}
`,
})
await execa('nuxt', ['build'])
const childProcess = execa('nuxt', ['start'])
await execa.command('nuxt build')
const childProcess = execa.command('nuxt start')
try {
await portReady(3000)
await page.goto('http://localhost:3000')
Expand Down

0 comments on commit 2c1e1e6

Please sign in to comment.