Skip to content

Commit

Permalink
adjust output
Browse files Browse the repository at this point in the history
  • Loading branch information
yimysty committed Jun 18, 2022
1 parent 6547446 commit b3b31a1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
19 changes: 10 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14532,6 +14532,7 @@ exports.debug = debug; // for test
const fs = __nccwpck_require__(7147)
const espree = __nccwpck_require__(6910)
const format = __nccwpck_require__(3259)
const core = __nccwpck_require__(2186)

// Parse the AST
const espreeOptions = {
Expand Down Expand Up @@ -14595,7 +14596,7 @@ class ConfigParser {
}

parse() {
console.log(`original configuration:\n${this.config}`)
core.info(`original configuration:\n${this.config}`)
const ast = espree.parse(this.config, espreeOptions);

// Find the default export declaration node
Expand All @@ -14622,7 +14623,7 @@ class ConfigParser {
throw "Unknown config type"
}
}
console.log(`parsed configuration:\n${this.config}`)
core.info(`parsed configuration:\n${this.config}`)
fs.writeFileSync(this.staticSiteConfig.filePath, this.config)
return this.config
}
Expand All @@ -14634,13 +14635,13 @@ class ConfigParser {

if (!propertyNode) {

console.log("Unable to find property, insert it : " + this.staticSiteConfig.pathName)
core.info("Unable to find property, insert it : " + this.staticSiteConfig.pathName)
if (exportNode.expression.right.properties.length > 0) {
this.config = this.config.slice(0, exportNode.expression.right.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.expression.right.properties[0].range[0])
console.log("new config = \n" + this.config)
core.info("new config = \n" + this.config)
} else {
this.config = this.config.slice(0, exportNode.expression.right.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.expression.right.range[1] - 1)
console.log("new config = \n" + this.config)
core.info("new config = \n" + this.config)
}
}
return propertyNode
Expand All @@ -14653,13 +14654,13 @@ class ConfigParser {

if (!propertyNode) {

console.log("Unable to find property, insert it " + this.staticSiteConfig.pathName)
core.info("Unable to find property, insert it " + this.staticSiteConfig.pathName)
if (exportNode.declaration.properties.length > 0) {
this.config = this.config.slice(0, exportNode.declaration.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.declaration.properties[0].range[0])
console.log("new config = \n" + this.config)
core.info("new config = \n" + this.config)
} else {
this.config = this.config.slice(0, exportNode.declaration.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.declaration.range[1] - 1)
console.log("new config = \n" + this.config)
core.info("new config = \n" + this.config)
}
}

Expand Down Expand Up @@ -14783,7 +14784,6 @@ async function getPagesBaseUrl({ repositoryNwo, githubToken, staticSiteGenerator
if ( staticSiteGenerator ) {
setPagesPath({staticSiteGenerator, path: siteUrl.pathname})
}

core.setOutput('base_url', siteUrl.href)
core.setOutput('origin', siteUrl.origin)
core.setOutput('host', siteUrl.host)
Expand Down Expand Up @@ -14844,6 +14844,7 @@ async function setPagesPath({staticSiteGenerator, path}) {

} catch (error) {
core.error('Set pages path in the static site generator config failed', error)
console.log(error)
throw error
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions src/config-parser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require("fs")
const espree = require("espree")
const format = require("string-format")
const core = require('@actions/core')

// Parse the AST
const espreeOptions = {
Expand Down Expand Up @@ -64,7 +65,7 @@ class ConfigParser {
}

parse() {
console.log(`original configuration:\n${this.config}`)
core.info(`original configuration:\n${this.config}`)
const ast = espree.parse(this.config, espreeOptions);

// Find the default export declaration node
Expand All @@ -91,7 +92,7 @@ class ConfigParser {
throw "Unknown config type"
}
}
console.log(`parsed configuration:\n${this.config}`)
core.info(`parsed configuration:\n${this.config}`)
fs.writeFileSync(this.staticSiteConfig.filePath, this.config)
return this.config
}
Expand All @@ -103,13 +104,13 @@ class ConfigParser {

if (!propertyNode) {

console.log("Unable to find property, insert it : " + this.staticSiteConfig.pathName)
core.info("Unable to find property, insert it : " + this.staticSiteConfig.pathName)
if (exportNode.expression.right.properties.length > 0) {
this.config = this.config.slice(0, exportNode.expression.right.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.expression.right.properties[0].range[0])
console.log("new config = \n" + this.config)
core.info("new config = \n" + this.config)
} else {
this.config = this.config.slice(0, exportNode.expression.right.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.expression.right.range[1] - 1)
console.log("new config = \n" + this.config)
core.info("new config = \n" + this.config)
}
}
return propertyNode
Expand All @@ -122,13 +123,13 @@ class ConfigParser {

if (!propertyNode) {

console.log("Unable to find property, insert it " + this.staticSiteConfig.pathName)
core.info("Unable to find property, insert it " + this.staticSiteConfig.pathName)
if (exportNode.declaration.properties.length > 0) {
this.config = this.config.slice(0, exportNode.declaration.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.declaration.properties[0].range[0])
console.log("new config = \n" + this.config)
core.info("new config = \n" + this.config)
} else {
this.config = this.config.slice(0, exportNode.declaration.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.declaration.range[1] - 1)
console.log("new config = \n" + this.config)
core.info("new config = \n" + this.config)
}
}

Expand Down
1 change: 0 additions & 1 deletion src/get-pages-base-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ async function getPagesBaseUrl({ repositoryNwo, githubToken, staticSiteGenerator
if ( staticSiteGenerator ) {
setPagesPath({staticSiteGenerator, path: siteUrl.pathname})
}

core.setOutput('base_url', siteUrl.href)
core.setOutput('origin', siteUrl.origin)
core.setOutput('host', siteUrl.host)
Expand Down
1 change: 1 addition & 0 deletions src/set-pages-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async function setPagesPath({staticSiteGenerator, path}) {

} catch (error) {
core.error('Set pages path in the static site generator config failed', error)
console.log(error)
throw error
}
}
Expand Down

0 comments on commit b3b31a1

Please sign in to comment.