forked from dxatscale/sfpowerscripts
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(output): Add outputs as a key entity
sfpowerscripts will now add a folder called ouputs which will have various ouputs in text or markdown format. This could be utilized by the callers to pass comments to thec calling CI/CD function
- Loading branch information
1 parent
bb18d16
commit 1212814
Showing
4 changed files
with
73 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/sfpowerscripts-cli/src/outputs/FileOutputHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as fs from 'fs-extra'; | ||
import path from 'path'; | ||
|
||
export default class FileOutputHandler { | ||
static instance: FileOutputHandler; | ||
|
||
public static getInstance() { | ||
if (!FileOutputHandler.instance) | ||
FileOutputHandler.instance = new FileOutputHandler('.sfpowerscripts/outputs'); | ||
|
||
return FileOutputHandler.instance; | ||
} | ||
|
||
|
||
private constructor(private containerFolder: string) { | ||
fs.mkdirpSync(this.containerFolder); | ||
} | ||
|
||
public writeOutput(fileName: string, output: string ) { | ||
fs.writeFileSync(path.join(this.containerFolder, fileName), output); | ||
}; | ||
|
||
public appendOutput(fileName: string,output: string) { | ||
if (!fs.existsSync(path.join(this.containerFolder, fileName))) { | ||
fs.createFileSync(path.join(this.containerFolder, fileName)); | ||
} | ||
fs.appendFileSync(path.join(this.containerFolder, fileName), output); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters