Ensure directory exists before writing new file (#58801)
This commit is contained in:
@@ -7,8 +7,9 @@
|
|||||||
* https://github.com/github/token-scanning-service/blob/main/docs/public-docs
|
* https://github.com/github/token-scanning-service/blob/main/docs/public-docs
|
||||||
* directory to src/secret-scanning/data/pattern-docs
|
* directory to src/secret-scanning/data/pattern-docs
|
||||||
*/
|
*/
|
||||||
import { writeFile } from 'fs/promises'
|
import { writeFile, mkdir } from 'fs/promises'
|
||||||
import yaml from 'js-yaml'
|
import yaml from 'js-yaml'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
import { getDirectoryContents } from '@/workflows/git-utils'
|
import { getDirectoryContents } from '@/workflows/git-utils'
|
||||||
import schema from '@/secret-scanning/data/public-docs-schema'
|
import schema from '@/secret-scanning/data/public-docs-schema'
|
||||||
@@ -52,6 +53,7 @@ async function main() {
|
|||||||
const filePath = file.path.replace(`${directory}/`, '')
|
const filePath = file.path.replace(`${directory}/`, '')
|
||||||
const localFilePath = `${SECRET_SCANNING_DIR}/${filePath}`
|
const localFilePath = `${SECRET_SCANNING_DIR}/${filePath}`
|
||||||
|
|
||||||
|
await mkdir(path.dirname(localFilePath), { recursive: true })
|
||||||
await writeFile(localFilePath, yaml.dump(yamlData))
|
await writeFile(localFilePath, yaml.dump(yamlData))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user