Skip to content

Commit

Permalink
Apply consistent spacing and use of single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMGreene committed Sep 11, 2022
1 parent 35c001d commit 45efe60
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 114 deletions.
18 changes: 9 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15438,7 +15438,7 @@ class ConfigParser {
throw 'Could not find a configuration object in the configuration file'
}

// A property may be nested in the configuration file. Split the property name with `.`
// A property may be nested in the configuration file. Split the property name with '.'
// then walk the configuration object one property at a time.
var depth = 0
const properties = propertyName.split('.')
Expand Down Expand Up @@ -15519,7 +15519,7 @@ class ConfigParser {
}

// Logging
core.info(`Injection successful, new configuration:`)
core.info('Injection successful, new configuration:')
core.info(this.configuration)

// Finally write the new configuration in the file
Expand Down Expand Up @@ -15609,7 +15609,7 @@ const removeTrailingSlash = __nccwpck_require__(9255)
// Return the settings to be passed to a {ConfigParser} for a given static site generator,
// optional configuration file path, and a Pages siteUrl value to inject
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
let { pathname, origin } = siteUrl
let { pathname: path, origin } = siteUrl

switch (staticSiteGenerator) {
case 'nuxt':
Expand All @@ -15618,7 +15618,7 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, sit
blankConfigurationFile: __nccwpck_require__.ab + "nuxt.js",
properties: {
// Configure a base path on the router
'router.base': pathname,
'router.base': path,

// Set the target to static too
// https://nuxtjs.org/docs/configuration-glossary/configuration-target/
Expand All @@ -15627,14 +15627,14 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, sit
}
case 'next':
// Next does not want a trailing slash
pathname = removeTrailingSlash(pathname)
path = removeTrailingSlash(path)

return {
configurationFile: generatorConfigFile || './next.config.js',
blankConfigurationFile: __nccwpck_require__.ab + "next.js",
properties: {
// Configure a base path
basePath: pathname,
basePath: path,

// Disable server side image optimization too
// https://nextjs.org/docs/api-reference/next/image#unoptimized
Expand All @@ -15647,21 +15647,21 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, sit
blankConfigurationFile: __nccwpck_require__.ab + "gatsby.js",
properties: {
// Configure a path prefix
pathPrefix: pathname,
pathPrefix: path,
// Configure a site url
'siteMetadata.siteUrl': origin
}
}
case 'sveltekit':
// SvelteKit does not want a trailing slash
pathname = removeTrailingSlash(pathname)
path = removeTrailingSlash(path)

return {
configurationFile: generatorConfigFile || './svelte.config.js',
blankConfigurationFile: __nccwpck_require__.ab + "sveltekit.js",
properties: {
// Configure a base path
'kit.paths.base': pathname,
'kit.paths.base': path,
// Configure a prerender origin
'kit.prerender.origin': origin
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/config-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ConfigParser {
throw 'Could not find a configuration object in the configuration file'
}

// A property may be nested in the configuration file. Split the property name with `.`
// A property may be nested in the configuration file. Split the property name with '.'
// then walk the configuration object one property at a time.
var depth = 0
const properties = propertyName.split('.')
Expand Down Expand Up @@ -265,7 +265,7 @@ class ConfigParser {
}

// Logging
core.info(`Injection successful, new configuration:`)
core.info('Injection successful, new configuration:')
core.info(this.configuration)

// Finally write the new configuration in the file
Expand Down
100 changes: 50 additions & 50 deletions src/config-parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,146 +14,146 @@ const cases = [
//
{
property: 'property',
source: `export default {}`,
expected: `export default { property: "value" }`
source: 'export default {}',
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: 0 }`, // property exists and is a number
expected: `export default { property: "value" }`
source: 'export default { property: 0 }', // property exists and is a number
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: false }`, // property exists and is a boolean
expected: `export default { property: "value" }`
source: 'export default { property: false }', // property exists and is a boolean
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: "test" }`, // property exists and is a string
expected: `export default { property: "value" }`
source: 'export default { property: "test" }', // property exists and is a string
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: [1,2] }`, // property exists and is an array
expected: `export default { property: "value" }`
source: 'export default { property: [1,2] }', // property exists and is an array
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: null }`, // property exists and is null
expected: `export default { property: "value" }`
source: 'export default { property: null }', // property exists and is null
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: {}}`, // property exists and is an object
expected: `export default { property: "value" }`
source: 'export default { property: { } }', // property exists and is an object
expected: 'export default { property: "value" }'
},

// Deep properties (injection 1)
{
property: 'property.b.c',
source: `export default {}`,
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default {}',
expected: 'export default { property: { b: { c: "value" } } }'
},
{
property: 'property.b.c',
source: `export default { property: 0 }`, // property exists and is a number
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default { property: 0 }', // property exists and is a number
expected: 'export default { property: { b: { c: "value" } } }'
},
{
property: 'property.b.c',
source: `export default { property: {}}`, // property exists and is an object
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default { property: { } }', // property exists and is an object
expected: 'export default { property: { b: { c: "value" } } }'
},

// Deep properties (injection 2)
{
property: 'property.b.c',
source: `export default { property: { b: 0 }}`, // property exists and is a number
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default { property: { b: 0 } }', // property exists and is a number
expected: 'export default { property: { b: { c: "value" } } }'
},
{
property: 'property.b.c',
source: `export default { property: { b: {}}}`, // property exists and is an object
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default { property: { b: { } } }', // property exists and is an object
expected: 'export default { property: { b: { c: "value" } } }'
},
{
property: 'property.b.c',
source: `export default { property: { b: { hello: 123}}}`, // property exists and is a non-empty object
expected: `export default { property: { b: { c: "value", hello: 123 }}}`
source: 'export default { property: { b: { hello: 123 } } }', // property exists and is a non-empty object
expected: 'export default { property: { b: { c: "value", hello: 123 } } }'
},

// Deep properties (existing properties)
{
property: 'a1.a2',
source: `export default { a2: false, a1: { a3: [12]}}`, // property exists and is a non-empty object
expected: `export default { a2: false, a1: { a2: "value", a3: [12]}}`
source: 'export default { a2: false, a1: { a3: [12] } }', // property exists and is a non-empty object
expected: 'export default { a2: false, a1: { a2: "value", a3: [12] } }'
},

//
// Indirect default export
//
{
property: 'property',
source: `const config = {}; export default config`,
expected: `const config = { property: "value"}; export default config`
source: 'const config = {}; export default config',
expected: 'const config = { property: "value"}; export default config'
},
{
property: 'property',
source: `var config = {}; export default config`,
expected: `var config = { property: "value"}; export default config`
source: 'var config = {}; export default config',
expected: 'var config = { property: "value"}; export default config'
},
{
property: 'a.b.c',
source: `var config = {}; export default config`,
expected: `var config = { a: { b: { c: "value"}}}; export default config`
source: 'var config = {}; export default config',
expected: 'var config = { a: { b: { c: "value" } } }; export default config'
},
{
property: 'a.b.c',
source: `var config = { a: { b: [], c: "hello"}}; export default config`,
expected: `var config = { a: { b: { c: "value"}, c: "hello"}}; export default config`
source: 'var config = { a: { b: [], c: "hello" } }; export default config',
expected: 'var config = { a: { b: { c: "value"}, c: "hello" } }; export default config'
},

//
// Direct module exports
//
{
property: 'property',
source: `module.exports = {}`,
expected: `module.exports = { property: "value"}`
source: 'module.exports = {}',
expected: 'module.exports = { property: "value"}'
},
{
property: 'property',
source: `module.exports = { p1: 0}`,
expected: `module.exports = { property: "value", p1: 0}`
source: 'module.exports = { p1: 0}',
expected: 'module.exports = { property: "value", p1: 0}'
},
{
property: 'a.b.c',
source: `module.exports = { p1: 0}`,
expected: `module.exports = { a: { b: { c: "value" }}, p1: 0}`
source: 'module.exports = { p1: 0}',
expected: 'module.exports = { a: { b: { c: "value" } }, p1: 0}'
},

//
// Indirect module exports
//
{
property: 'property',
source: `const config = {}; module.exports = config`,
expected: `const config = { property: "value"}; module.exports = config`
source: 'const config = {}; module.exports = config',
expected: 'const config = { property: "value"}; module.exports = config'
},
{
property: 'property',
source: `var config = {}; module.exports = config`,
expected: `var config = { property: "value"}; module.exports = config`
source: 'var config = {}; module.exports = config',
expected: 'var config = { property: "value"}; module.exports = config'
},
{
property: 'a.b.c',
source: `var config = {}; module.exports = config`,
expected: `var config = { a: { b: { c: "value"}}}; module.exports = config`
source: 'var config = {}; module.exports = config',
expected: 'var config = { a: { b: { c: "value" } } }; module.exports = config'
},
{
property: 'a.b.c',
source: `var config = { a: { b: [], c: "hello"}}; module.exports = config`,
expected: `var config = { a: { b: { c: "value"}, c: "hello"}}; module.exports = config`
source: 'var config = { a: { b: [], c: "hello" } }; module.exports = config',
expected: 'var config = { a: { b: { c: "value"}, c: "hello" } }; module.exports = config'
}
]

Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/gatsby/default.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
siteMetadata: {
title: `My Gatsby Site`
title: 'My Gatsby Site'
},
plugins: []
}
2 changes: 1 addition & 1 deletion src/fixtures/gatsby/default.expected.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
pathPrefix: '/docs/',
siteMetadata: {
siteUrl: 'https://configure-pages.github.io',
title: `My Gatsby Site`
title: 'My Gatsby Site'
},
plugins: []
}
2 changes: 1 addition & 1 deletion src/fixtures/gatsby/default.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
pathPrefix: '/docs/',
siteMetadata: {
siteUrl: 'https://configure-pages.github.io',
title: `My Gatsby Site`
title: 'My Gatsby Site'
},
plugins: []
}
2 changes: 1 addition & 1 deletion src/fixtures/gatsby/default.expected.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
pathPrefix: '/docs/',
siteMetadata: {
siteUrl: 'https://configure-pages.github.io',
title: `My Gatsby Site`
title: 'My Gatsby Site'
},
plugins: []
}
2 changes: 1 addition & 1 deletion src/fixtures/gatsby/default.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
siteMetadata: {
title: `My Gatsby Site`
title: 'My Gatsby Site'
},
plugins: []
}
2 changes: 1 addition & 1 deletion src/fixtures/gatsby/default.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
siteMetadata: {
title: `My Gatsby Site`
title: 'My Gatsby Site'
},
plugins: []
}
2 changes: 1 addition & 1 deletion src/fixtures/next/default.expected.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {images: {unoptimized: true}},
experimental: { images: { unoptimized: true } },
basePath: '/docs',
reactStrictMode: true,
swcMinify: true
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/next/default.expected.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {images: {unoptimized: true}},
experimental: { images: { unoptimized: true } },
basePath: '/docs',
reactStrictMode: true,
swcMinify: true
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/nuxt/async.expected.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const getAllDynamicRoute = async function() {

module.exports = {
target: 'static',
router: {base: '/docs/'},
router: { base: '/docs/' },
mode: 'universal',
generate: {
async routes () {
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/nuxt/async.expected.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const getAllDynamicRoute = async function() {

export default {
target: 'static',
router: {base: '/docs/'},
router: { base: '/docs/' },
mode: 'universal',
generate: {
async routes () {
Expand Down
Loading

0 comments on commit 45efe60

Please sign in to comment.