44 *
55 * Usage:
66 * npm run copy:content-engine
7+ *
8+ * Optional:
9+ * CONTENT_ENGINE_DESTINATION_ROOT=/path/to/cse-content-engine/content/learning-pathways/copilot-cli-for-beginners npm run copy:content-engine
710 */
811
912const {
@@ -12,13 +15,18 @@ const {
1215 mkdirSync,
1316 readdirSync,
1417 readFileSync,
18+ rmSync,
1519 statSync,
1620 writeFileSync,
1721} = require ( 'fs' ) ;
1822const { dirname, join, relative, resolve } = require ( 'path' ) ;
1923
2024const sourceRoot = process . cwd ( ) ;
21- const destinationRoot = '/Users/danwahlin/Desktop/projects/cse-content-engine/content/learning-pathways/copilot-cli-for-beginners' ;
25+ const defaultDestinationRoot = resolve (
26+ sourceRoot ,
27+ '../cse-content-engine/content/learning-pathways/copilot-cli-for-beginners' ,
28+ ) ;
29+ const destinationRoot = resolve ( process . env . CONTENT_ENGINE_DESTINATION_ROOT || defaultDestinationRoot ) ;
2230const destinationParent = dirname ( destinationRoot ) ;
2331const contentEngineSchema = {
2432 $schema : 'http://json-schema.org/draft-07/schema#' ,
@@ -95,6 +103,11 @@ function ensureSafeDestination() {
95103 }
96104}
97105
106+ function resetDestination ( ) {
107+ rmSync ( destinationRoot , { recursive : true , force : true } ) ;
108+ log ( `Cleared ${ destinationRoot } ` ) ;
109+ }
110+
98111function copyFile ( sourcePath , destinationPath ) {
99112 mkdirSync ( dirname ( destinationPath ) , { recursive : true } ) ;
100113
@@ -333,6 +346,7 @@ function validateMarkdownFrontmatter() {
333346}
334347
335348ensureSafeDestination ( ) ;
349+ resetDestination ( ) ;
336350copyCourseContent ( ) ;
337351validateMarkdownFrontmatter ( ) ;
338352validateMarkdownImagePaths ( ) ;
0 commit comments