lib/setup/folder.js
/**
 * Create a temprary theme folder linking the files of the original theme folder
 *
 * Create a temporary folder, pick the best theme folder among all possible
 * theme sources, link the original theme files so that we can create and
 * manipulate them safely and repeateadly.
 *
 * @param {string} src The path of the original source folder
 * @param {string} theme The path or name of the theme to use
 * @returns {string} The path to the temporary folder
 */
Create a temprary theme folder linking the files of the original theme folder
Create a temporary folder, pick the best theme folder among all possible
theme sources, link the original theme files so that we can create and
manipulate them safely and repeateadly.

@param {string} src The path of the original source folder
@param {string} theme The path or name of the theme to use
@returns {string} The path to the temporary folder
Create a temprary theme folder linking the files of the original theme folder Create a temporary folder pick the best theme folder among all possible theme sources link the original theme files so that we can create and manipulate them safely and repeateadly . @param { string } src The path of the original source folder @param { string } theme The path or name of the theme to use @returns { string } The path to the temporary folder
async function createSafeThemeFolder (src, theme) {
  const TMP_DIRECTORY = path.join(os.tmpdir(), `stuffme-${(await randomBytes(8)).toString(`hex`)}`)
  const source = await getThemeFolder(theme, path.join(src, `theme`))
   TODO: Shouldn't we copy css files instead of linking them in order
         to prevent rewriting them while compiling Sass files? (for example
         if we have both foo.css and foo.sass in the same folder, the Sass
         compilation will overwrite the foo.css file)
  const linking = (await readDirDeep(source, { withFileTypes: true }))
    .filter(entry => !entry.isDirectory())
    .map(makeLink(source, TMP_DIRECTORY))
  await Promise.all(linking)
  return TMP_DIRECTORY
}
async function createSafeThemeFolder ( src , theme ) { const TMP_DIRECTORY = path . join ( os . tmpdir ( ) , ` ${ ( await randomBytes ( 8 ) ) . toString ( ` ` ) } ` ) const source = await getThemeFolder ( theme , path . join ( src , ` ` ) ) const linking = ( await readDirDeep ( source , { withFileTypes : true } ) ) . filter ( entry => ! entry . isDirectory ( ) ) . map ( makeLink ( source , TMP_DIRECTORY ) ) await Promise . all ( linking ) return TMP_DIRECTORY }
Create a temprary theme folder linking the files of the original theme folder
 Create a temporary folder, pick the best theme folder among all possible
 theme sources, link the original theme files so that we can create and
 manipulate them safely and repeateadly.
Create a temprary theme folder linking the files of the original theme folder Create a temporary folder pick the best theme folder among all possible theme sources link the original theme files so that we can create and manipulate them safely and repeateadly .
// By creating our temporary directory into the OS tmp folder, we make // sure that if the process end badly, our folder will be removed by // the OS cleaning routine. // Let's retrieve the most accurate them folder. // We link all the file from the original them folder // into our safe theme folder. Among many things it will // let us compile sass file without adding the resulting files // into the original theme folder. // // TODO: Shouldn't we copy css files instead of linking them in order //       to prevent rewriting them while compiling Sass files? (for example //       if we have both foo.css and foo.sass in the same folder, the Sass //       compilation will overwrite the foo.css file)