nuxt-i18n
Advanced tools
Comparing version 3.2.3 to 3.2.4
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="3.2.4"></a> | ||
## [3.2.4](https://github.com/nuxt-community/nuxt-i18n/compare/v3.2.3...v3.2.4) (2018-05-27) | ||
<a name="3.2.3"></a> | ||
@@ -7,0 +12,0 @@ ## [3.2.3](https://github.com/nuxt-community/nuxt-i18n/compare/v3.2.2...v3.2.3) (2018-05-10) |
{ | ||
"name": "nuxt-i18n", | ||
"version": "3.2.3", | ||
"version": "3.2.4", | ||
"description": "i18n for Nuxt", | ||
@@ -64,5 +64,5 @@ "license": "MIT", | ||
"nuxt": "npm:nuxt-edge", | ||
"standard-version": "latest", | ||
"vuepress": "^0.8.4" | ||
"standard-version": "^4.4.0", | ||
"vuepress": "0.10.0" | ||
} | ||
} |
@@ -1,18 +0,18 @@ | ||
import { readFileSync } from 'fs' | ||
import {readFileSync} from 'fs' | ||
import acorn from 'acorn' | ||
import walker from 'acorn/dist/walk' | ||
import {COMPONENT_OPTIONS_KEY} from './constants' | ||
import { COMPONENT_OPTIONS_KEY } from './constants' | ||
const compiler = require('vue-template-compiler') | ||
export const extractComponentOptions = (path) => { | ||
let componentOptions = {} | ||
const pattern = new RegExp(/<script[^>]*>((.|\n)+)<\/script>/, 'i') | ||
const content = readFileSync(path).toString() | ||
const matches = content.match(pattern) | ||
if (!matches || matches.length < 2) { | ||
let Component = compiler.parseComponent(readFileSync(path).toString()) | ||
if (!Component.script || Component.script.content.length < 1) { | ||
return componentOptions | ||
} | ||
const script = matches[1] | ||
const script = Component.script.content | ||
const parsed = acorn.parse(script, { | ||
ecmaVersion: 8, | ||
ecmaVersion: 9, | ||
sourceType: 'module' | ||
@@ -28,3 +28,4 @@ }) | ||
}) | ||
return componentOptions | ||
} |
31535
15
715