From 92c7f4ed249466870a477798f910c84eb1fdd18d Mon Sep 17 00:00:00 2001 From: Snir Shechter Date: Sun, 29 Sep 2019 12:06:44 +0300 Subject: [PATCH] feat(builder): `followSymlinks` option to allow for symlinks (#6368) --- packages/builder/src/builder.js | 3 ++- packages/config/src/config/build.js | 3 ++- .../config/test/__snapshots__/options.test.js.snap | 1 + .../test/config/__snapshots__/index.test.js.snap | 2 ++ test/fixtures/basic/nuxt.config.js | 1 + .../basic/pages/symlink/deep/nested-symlinked.vue | 3 +++ test/fixtures/basic/pages/symlink/symlinked.vue | 3 +++ test/fixtures/basic/pages2/deep/nested-symlinked.vue | 3 +++ test/fixtures/basic/pages2/symlinked.vue | 3 +++ test/unit/basic.ssr.test.js | 10 ++++++++++ 10 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/basic/pages/symlink/deep/nested-symlinked.vue create mode 100644 test/fixtures/basic/pages/symlink/symlinked.vue create mode 100644 test/fixtures/basic/pages2/deep/nested-symlinked.vue create mode 100644 test/fixtures/basic/pages2/symlinked.vue diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js index 874ca5a553..4cee71cfd2 100644 --- a/packages/builder/src/builder.js +++ b/packages/builder/src/builder.js @@ -310,7 +310,8 @@ export default class Builder { async resolveFiles (dir, cwd = this.options.srcDir) { return this.ignore.filter(await glob(this.globPathWithExtensions(dir), { cwd, - ignore: this.options.ignore + ignore: this.options.ignore, + follow: this.options.build.followSymlinks })) } diff --git a/packages/config/src/config/build.js b/packages/config/src/config/build.js index 4a441a61b5..c0c5eaa42d 100644 --- a/packages/config/src/config/build.js +++ b/packages/config/src/config/build.js @@ -118,5 +118,6 @@ export default () => ({ }, friendlyErrors: true, additionalExtensions: [], - warningIgnoreFilters: [] + warningIgnoreFilters: [], + followSymlinks: false }) diff --git a/packages/config/test/__snapshots__/options.test.js.snap b/packages/config/test/__snapshots__/options.test.js.snap index 1bcf8cdc58..e8798e12d7 100644 --- a/packages/config/test/__snapshots__/options.test.js.snap +++ b/packages/config/test/__snapshots__/options.test.js.snap @@ -39,6 +39,7 @@ Object { "img": [Function], "video": [Function], }, + "followSymlinks": false, "friendlyErrors": true, "hardSource": false, "hotMiddleware": Object {}, diff --git a/packages/config/test/config/__snapshots__/index.test.js.snap b/packages/config/test/config/__snapshots__/index.test.js.snap index 09eddd6fd1..88799244b7 100644 --- a/packages/config/test/config/__snapshots__/index.test.js.snap +++ b/packages/config/test/config/__snapshots__/index.test.js.snap @@ -26,6 +26,7 @@ Object { "img": [Function], "video": [Function], }, + "followSymlinks": false, "friendlyErrors": true, "hardSource": false, "hotMiddleware": Object {}, @@ -376,6 +377,7 @@ Object { "img": [Function], "video": [Function], }, + "followSymlinks": false, "friendlyErrors": true, "hardSource": false, "hotMiddleware": Object {}, diff --git a/test/fixtures/basic/nuxt.config.js b/test/fixtures/basic/nuxt.config.js index 74d5a6e74b..f350ceefbf 100644 --- a/test/fixtures/basic/nuxt.config.js +++ b/test/fixtures/basic/nuxt.config.js @@ -77,6 +77,7 @@ export default { build: { scopeHoisting: true, publicPath: '', + followSymlinks: true, postcss: { preset: { features: { diff --git a/test/fixtures/basic/pages/symlink/deep/nested-symlinked.vue b/test/fixtures/basic/pages/symlink/deep/nested-symlinked.vue new file mode 100644 index 0000000000..5f2d4a4ff6 --- /dev/null +++ b/test/fixtures/basic/pages/symlink/deep/nested-symlinked.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/basic/pages/symlink/symlinked.vue b/test/fixtures/basic/pages/symlink/symlinked.vue new file mode 100644 index 0000000000..2a7c4a1c97 --- /dev/null +++ b/test/fixtures/basic/pages/symlink/symlinked.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/basic/pages2/deep/nested-symlinked.vue b/test/fixtures/basic/pages2/deep/nested-symlinked.vue new file mode 100644 index 0000000000..5f2d4a4ff6 --- /dev/null +++ b/test/fixtures/basic/pages2/deep/nested-symlinked.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/basic/pages2/symlinked.vue b/test/fixtures/basic/pages2/symlinked.vue new file mode 100644 index 0000000000..2a7c4a1c97 --- /dev/null +++ b/test/fixtures/basic/pages2/symlinked.vue @@ -0,0 +1,3 @@ + diff --git a/test/unit/basic.ssr.test.js b/test/unit/basic.ssr.test.js index c0fa38202a..74267d4583 100644 --- a/test/unit/basic.ssr.test.js +++ b/test/unit/basic.ssr.test.js @@ -358,6 +358,16 @@ describe('basic ssr', () => { expect(html).toMatch('

JS Layout

') expect(html).toMatch('

custom page

') }) + /* Testing symlinks functionality */ + test('/symlink/symlinked', async () => { + const { html } = await nuxt.server.renderRoute('/symlink/symlinked') + expect(html).toContain('

Symlinked page

') + }) + + test('/symlink/deep/nested-symlinked', async () => { + const { html } = await nuxt.server.renderRoute('/symlink/deep/nested-symlinked') + expect(html).toContain('

Nested symlink page

') + }) // Close server and ask nuxt to stop listening to file changes afterAll(async () => {