mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
chore: fix dev version
fixes components version check during nuxt development
This commit is contained in:
parent
e1de5e8667
commit
12d6702eba
@ -56,7 +56,7 @@ export default class Nuxt extends Hookable {
|
||||
}
|
||||
|
||||
static get version () {
|
||||
return (global.__NUXT && global.__NUXT.version) || `v${version}`
|
||||
return `v${version}` + (global.__NUXT_DEV__ ? '-development' : '')
|
||||
}
|
||||
|
||||
ready () {
|
||||
|
@ -80,16 +80,6 @@ describe('core: nuxt', () => {
|
||||
expect(Nuxt.version).toEqual(`v${version}`)
|
||||
})
|
||||
|
||||
test('should return nuxt version from global.__NUXT', () => {
|
||||
global.__NUXT = {
|
||||
version: 'latest'
|
||||
}
|
||||
|
||||
expect(Nuxt.version).toEqual('latest')
|
||||
|
||||
delete global.__NUXT
|
||||
})
|
||||
|
||||
test('should call module/server ready in nuxt.ready', async () => {
|
||||
const nuxt = new Nuxt()
|
||||
|
||||
|
@ -12,38 +12,8 @@ const useCjs = [
|
||||
const stub = {
|
||||
es: 'export * from \'../src/index\'',
|
||||
cjs: `const _require = typeof jest === 'undefined' ? require('esm')(module) : require
|
||||
|
||||
const execa = require('execa')
|
||||
|
||||
global.__NUXT = {}
|
||||
Object.defineProperty(global.__NUXT, 'version', {
|
||||
enumerable: true,
|
||||
get() {
|
||||
try {
|
||||
const { stdout } = execa.sync('git', ['status', '-s', '-b', '--porcelain=2'])
|
||||
|
||||
const status = { dirty: false }
|
||||
for (const line of stdout.split('\\n')) {
|
||||
if (line[0] === '#') {
|
||||
const match = line.match(/branch\\.([^\\s]+) (.*)$/)
|
||||
if (match && match.length) {
|
||||
status[match[1]] = match[2]
|
||||
}
|
||||
} else {
|
||||
status.dirty = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return \`git<\${status.head}\${status.dirty ? '~' : '-'}\${(status.oid && status.oid.substr(0, 7)) || ''}>\` +
|
||||
(status.ab ? \` (\${status.ab})\` : '')
|
||||
} catch (err) {
|
||||
return 'source'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = _require('../src/index')
|
||||
global.__NUXT_DEV__ = true
|
||||
module.exports = _require('../src/index')
|
||||
`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user