Skip to content

Commit

Permalink
fix: create static-json dir at correct point in generate lifecycle
Browse files Browse the repository at this point in the history
Fixes error "Error: ENOENT: no such file or directory, mkdir
'.nuxt/static-json'"
  • Loading branch information
danielroe committed Jul 9, 2020
1 parent 89550df commit 2d4e10b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
"watch": "yarn compile -w",
"clean": "rm -rf lib/*",
"compile": "rollup -c",
"clean:fixture": "rm -rf dist/ test/fixture/.nuxt",
"fixture": "yarn nuxt-run dev",
"fixture:prod": "rm -rf .nuxt && yarn nuxt-run build && yarn nuxt-run start",
"fixture:generate:export": "export GENERATE=true && rm -rf .nuxt && yarn nuxt-run build && PORT=6000 yarn nuxt-run export",
"fixture:prod": "yarn clean:fixture && yarn nuxt-run build && yarn nuxt-run start",
"fixture:generate:export": "yarn clean:fixture && export GENERATE=true && yarn nuxt-run build && PORT=6000 yarn nuxt-run export",
"fixture:generate": "yarn fixture:generate:export && yarn http-server -s -p 5000 dist",
"lint": "run-s lint:all:*",
"lint:all:eslint": "yarn lint:eslint --ext .js,.ts,.vue .",
Expand Down
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve, join } from 'path'
import { rmdirSync, readdirSync, copyFileSync, existsSync, mkdirSync } from 'fs'
import { readdirSync, copyFileSync, existsSync, mkdirpSync } from 'fs-extra'

import type { Module } from '@nuxt/types'

Expand Down Expand Up @@ -28,9 +28,8 @@ const compositionApiModule: Module<any> = function () {

const staticPath = join(this.options.buildDir || '', 'static-json')

this.nuxt.hook('generate:before', () => {
if (existsSync(staticPath)) rmdirSync(staticPath)
mkdirSync(staticPath)
this.nuxt.hook('generate:route', () => {
mkdirpSync(staticPath)
})

this.nuxt.hook('generate:done', async (generator: any) => {
Expand Down

0 comments on commit 2d4e10b

Please sign in to comment.