2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-21 13:10:33 +03:00

chore: fix lint

This commit is contained in:
pimlie
2019-07-11 21:43:05 +02:00
parent 1d9072a3af
commit 56f6577e25
40 changed files with 105 additions and 107 deletions
+8 -8
View File
@@ -3,11 +3,11 @@ import puppeteer from 'puppeteer-core'
import ChromeDetector from './chrome'
export default class Browser {
constructor() {
constructor () {
this.detector = new ChromeDetector()
}
async start(options = {}) {
async start (options = {}) {
// https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions
const _opts = {
args: [
@@ -25,13 +25,13 @@ export default class Browser {
this.browser = await puppeteer.launch(_opts)
}
async close() {
if (!this.browser) return
async close () {
if (!this.browser) { return }
await this.browser.close()
}
async page(url, globalName = 'vueMeta') {
if (!this.browser) throw new Error('Please call start() before page(url)')
async page (url, globalName = 'vueMeta') {
if (!this.browser) { throw new Error('Please call start() before page(url)') }
const page = await this.browser.newPage()
// pass on console messages
@@ -69,7 +69,7 @@ export default class Browser {
page.$vueMeta = await page.evaluateHandle(page.$globalHandle)
page.vueMeta = {
async navigate(path, waitEnd = true) {
async navigate (path, waitEnd = true) {
const hook = page.evaluate(`
new Promise(resolve =>
${page.$globalHandle}.$once('routeChanged', resolve)
@@ -85,7 +85,7 @@ export default class Browser {
}
return { hook }
},
routeData() {
routeData () {
return page.evaluate(($vueMeta) => {
return {
path: $vueMeta.$route.path,
+3 -3
View File
@@ -7,7 +7,7 @@ import { createRenderer } from 'vue-server-renderer'
const renderer = createRenderer()
export function webpackRun(config) {
export function webpackRun (config) {
const compiler = webpack(config)
return new Promise((resolve, reject) => {
@@ -21,7 +21,7 @@ export function webpackRun(config) {
})
}
export async function buildFixture(fixture, config = {}) {
export async function buildFixture (fixture, config = {}) {
if (!fixture) {
throw new Error('buildFixture should be called with a fixture name')
}
@@ -69,7 +69,7 @@ export async function buildFixture(fixture, config = {}) {
}
}
export function createWebpackConfig(config = {}) {
export function createWebpackConfig (config = {}) {
const publicPath = '.vue-meta'
return {
+12 -12
View File
@@ -17,19 +17,19 @@ const newLineRegex = /\r?\n/
* https://github.com/gwuhaolin/chrome-finder
*/
export default class ChromeDetector {
constructor() {
constructor () {
this.platform = isWsl ? 'wsl' : process.platform
}
detect(platform = this.platform) {
detect (platform = this.platform) {
const handler = this[platform]
if (typeof handler !== 'function') {
throw new Error(`${platform} is not supported.`)
throw new TypeError(`${platform} is not supported.`)
}
return this[platform]()[0]
}
darwin() {
darwin () {
const suffixes = [
'/Contents/MacOS/Chromium',
'/Contents/MacOS/Google Chrome Canary',
@@ -88,7 +88,7 @@ export default class ChromeDetector {
* 2. Look into the directories where .desktop are saved on gnome based distro's
* 3. Look for google-chrome-stable & google-chrome executables by using the which command
*/
linux() {
linux () {
let installations = []
// 1. Look into CHROME_PATH env variable
const customChromePath = this.resolveChromePath()
@@ -147,7 +147,7 @@ export default class ChromeDetector {
return this.sort(uniq(installations.filter(Boolean)), priorities)
}
wsl() {
wsl () {
// Manually populate the environment variables assuming it's the default config
process.env.LOCALAPPDATA = this.getLocalAppDataPath(process.env.PATH)
process.env.PROGRAMFILES = '/mnt/c/Program Files'
@@ -155,7 +155,7 @@ export default class ChromeDetector {
return this.win32()
}
win32() {
win32 () {
const installations = []
const sep = path.sep
const suffixes = [
@@ -185,7 +185,7 @@ export default class ChromeDetector {
return installations
}
resolveChromePath() {
resolveChromePath () {
if (this.canAccess(process.env.CHROME_PATH)) {
return process.env.CHROME_PATH
}
@@ -198,13 +198,13 @@ export default class ChromeDetector {
}
}
getLocalAppDataPath(path) {
getLocalAppDataPath (path) {
const userRegExp = /\/mnt\/([a-z])\/Users\/([^/:]+)\/AppData\//
const results = userRegExp.exec(path) || []
return `/mnt/${results[1]}/Users/${results[2]}/AppData/Local`
}
sort(installations, priorities) {
sort (installations, priorities) {
const defaultPriority = 10
return installations
.map((inst) => {
@@ -219,7 +219,7 @@ export default class ChromeDetector {
.map(pair => pair.path)
}
canAccess(file) {
canAccess (file) {
if (!file) {
return false
}
@@ -231,7 +231,7 @@ export default class ChromeDetector {
}
}
findChromeExecutables(folder) {
findChromeExecutables (folder) {
const argumentsRegex = /(^[^ ]+).*/ // Take everything up to the first space
const chromeExecRegex = '^Exec=/.*/(google-chrome|chrome|chromium)-.*'
const installations = []
+2 -2
View File
@@ -13,11 +13,11 @@ export {
VueMetaServerPlugin
}
export function getVue() {
export function getVue () {
return createLocalVue()
}
export function loadVueMetaPlugin(browser, options, localVue = getVue()) {
export function loadVueMetaPlugin (browser, options, localVue = getVue()) {
if (browser) {
localVue.use(VueMetaBrowserPlugin, Object.assign({}, defaultOptions, options))
} else {
+3 -3
View File
@@ -5,7 +5,7 @@ const metaInfoData = {
add: {
data: 'Hello World',
expect: ['<title>Hello World</title>'],
test(side, defaultTest) {
test (side, defaultTest) {
if (side === 'client') {
// client side vue-meta uses document.title and doesnt change the html
return () => {
@@ -65,7 +65,7 @@ const metaInfoData = {
'<meta data-vue-meta="test" charset="utf-16">',
'<meta data-vue-meta="test" property="a" content="c">'
],
test(side, defaultTest) {
test (side, defaultTest) {
if (side === 'client') {
return () => {
const tags = defaultTest()
@@ -120,7 +120,7 @@ const metaInfoData = {
'<script data-vue-meta="test" src="src" defer data-vmid="content"></script>',
'<script data-vue-meta="test" src="src" defer data-body="true"></script>'
],
test(side, defaultTest) {
test (side, defaultTest) {
return () => {
if (side === 'client') {
for (const index in this.expect) {