Skip to content

Commit a3be967

Browse files
fix(sasjs-build): recognise global targets, fix compile-build logic (#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
1 parent 2581710 commit a3be967

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/commands/build.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export async function build(
9191
console.log(chalk.white('Skipping compiling of build folders...'))
9292
} else {
9393
console.log(chalk.redBright(result.message))
94-
await compile()
94+
await compile(targetName)
9595
}
9696

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

958-
const subFolders = await getSubFoldersInFolder(buildDestinationServ)
958+
const serviceSubFolders = await getSubFoldersInFolder(buildDestinationServ)
959959

960960
const servicesPresent = servicesBuildFolders.every((folder) =>
961-
subFolders.includes(folder)
961+
serviceSubFolders.includes(folder)
962962
)
963+
964+
const jobSubFolders = await getSubFoldersInFolder(buildDestinationJobs)
965+
963966
const jobsPresent = jobsBuildFolders.every((folder) =>
964-
subFolders.includes(folder)
967+
jobSubFolders.includes(folder)
965968
)
966969

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

987990
if (returnObj.compiled) {
988991
await asyncForEach(jobsBuildFolders, async (buildFolder) => {
989-
const folderPath = path.join(buildDestinationServ, buildFolder)
992+
const folderPath = path.join(buildDestinationJobs, buildFolder)
990993
const subFolders = await getSubFoldersInFolder(folderPath)
991994
const filesNamesInPath = await getFilesInFolder(folderPath)
992995
if (subFolders.length == 0 && filesNamesInPath.length == 0) {

test/helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ global.addToGlobalConfigs = async (buildTarget) => {
191191
let globalConfig = await getGlobalRcFile()
192192
if (globalConfig) {
193193
if (globalConfig.targets && globalConfig.targets.length) {
194+
if (globalConfig.targets.some((t) => t.name === buildTarget.name)) {
195+
throw new Error('Target already exists.')
196+
}
194197
globalConfig.targets.push(buildTarget)
195198
} else {
196199
globalConfig.targets = [buildTarget]

0 commit comments

Comments
 (0)