Skip to content

Commit

Permalink
fix(sasjs-build): recognise global targets, fix compile-build logic (#…
Browse files Browse the repository at this point in the history
…246)

* fix(sasjs-build): recognise global targets

* fix(sasjs-build): fix destination folder paths in compile check

* chore(*): throw error in tests if target already exists
  • Loading branch information
krishna-acondy authored Nov 18, 2020
1 parent 2581710 commit a3be967
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export async function build(
console.log(chalk.white('Skipping compiling of build folders...'))
} else {
console.log(chalk.redBright(result.message))
await compile()
await compile(targetName)
}

await createFinalSasFiles()
Expand Down Expand Up @@ -955,13 +955,16 @@ async function validCompiled(servicesBuildFolders, jobsBuildFolders) {
message: `Build Folder doesn't exists: ${buildDestinationFolder}`
}

const subFolders = await getSubFoldersInFolder(buildDestinationServ)
const serviceSubFolders = await getSubFoldersInFolder(buildDestinationServ)

const servicesPresent = servicesBuildFolders.every((folder) =>
subFolders.includes(folder)
serviceSubFolders.includes(folder)
)

const jobSubFolders = await getSubFoldersInFolder(buildDestinationJobs)

const jobsPresent = jobsBuildFolders.every((folder) =>
subFolders.includes(folder)
jobSubFolders.includes(folder)
)

if (servicesPresent && jobsPresent) {
Expand All @@ -986,7 +989,7 @@ async function validCompiled(servicesBuildFolders, jobsBuildFolders) {

if (returnObj.compiled) {
await asyncForEach(jobsBuildFolders, async (buildFolder) => {
const folderPath = path.join(buildDestinationServ, buildFolder)
const folderPath = path.join(buildDestinationJobs, buildFolder)
const subFolders = await getSubFoldersInFolder(folderPath)
const filesNamesInPath = await getFilesInFolder(folderPath)
if (subFolders.length == 0 && filesNamesInPath.length == 0) {
Expand Down
3 changes: 3 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ global.addToGlobalConfigs = async (buildTarget) => {
let globalConfig = await getGlobalRcFile()
if (globalConfig) {
if (globalConfig.targets && globalConfig.targets.length) {
if (globalConfig.targets.some((t) => t.name === buildTarget.name)) {
throw new Error('Target already exists.')
}
globalConfig.targets.push(buildTarget)
} else {
globalConfig.targets = [buildTarget]
Expand Down

0 comments on commit a3be967

Please sign in to comment.