adjust output

This commit is contained in:
yimysty
2022-06-17 18:58:11 -07:00
parent 65474466b2
commit b3b31a1b5c
5 changed files with 21 additions and 19 deletions

View File

@@ -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 = {
@@ -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
@@ -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
}
@@ -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
@@ -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)
}
}

View File

@@ -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)

View File

@@ -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
}
}