Skip to content

Commit c518a10

Browse files
committed
fix(module): fix compatibility with nuxt generate
Properly copy `admin` folder to `dist`. Add `generate` snapshot. Fixes #59 Thanks @jmcmullen & @easherma!
1 parent 087bf52 commit c518a10

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

Diff for: src/module.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,12 @@ export default function NetlifyCmsModule(moduleOptions) {
185185
}
186186

187187
// Move cms folder from `dist/_nuxt` folder to `dist/` after nuxt generate
188-
this.nuxt.hook("generate", generator => {
189-
generator.hook("generate", async () => {
190-
await move(
191-
join(generator.distNuxtPath, config.adminPath).replace(/\/$/, ""),
192-
join(generator.distPath, config.adminPath).replace(/\/$/, "")
193-
);
194-
debug("Netlify CMS files copied");
195-
});
188+
this.nuxt.hook("generate:distCopied", async generator => {
189+
await move(
190+
join(generator.distNuxtPath, config.adminPath).replace(/\/$/, ""),
191+
join(generator.distPath, config.adminPath).replace(/\/$/, "")
192+
);
193+
debug("Netlify CMS files copied");
196194
});
197195
}
198196

Diff for: test/__snapshots__/generate.test.js.snap

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`module generate mode admin 1`] = `
4+
"<!DOCTYPE html>
5+
<html>
6+
<head>
7+
<meta charset=\\"utf-8\\" />
8+
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
9+
<link href=\\"/admin/config.yml\\" type=\\"text/yaml\\" rel=\\"cms-config-url\\">
10+
<title>Content Manager</title>
11+
</head>
12+
<body>
13+
<script type=\\"text/javascript\\" src=\\"/admin/bundle.e71f9cb57b0e8fbe149a.js\\"></script></body>
14+
</html>
15+
"
16+
`;

0 commit comments

Comments
 (0)