lib/setup/folder.js
/**
 * Create a temprary source folder linking the files of the original source folder
 *
 * Create a temporary folder and link the original source files so that we can
 * create and manipulate source safely and repeateadly. It also link the theme
 * folder and the reveal folder inside our temporary folder so that we have a
 * clean ready to use source folder with all its dependencies.
 *
 * @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 source folder linking the files of the original source folder
Create a temporary folder and link the original source files so that we can
create and manipulate source safely and repeateadly. It also link the theme
folder and the reveal folder inside our temporary folder so that we have a
clean ready to use source folder with all its dependencies.

@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 source folder linking the files of the original source folder Create a temporary folder and link the original source files so that we can create and manipulate source safely and repeateadly . It also link the theme folder and the reveal folder inside our temporary folder so that we have a clean ready to use source folder with all its dependencies . @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 createSafeSourceFolder (src, theme) {
  const TMP_DIRECTORY = path.join(os.tmpdir(), `stuffme-${(await randomBytes(8)).toString(`hex`)}`)
  const TMP_DIRECTORY_THEME = path.join(TMP_DIRECTORY, `theme`)
  const TMP_DIRECTORY_REVEAL = path.join(TMP_DIRECTORY, `reveal.js`)
  const linkingSRC = (await readDirDeep(src, { withFileTypes: true }))
    .filter(entry => {
      return (
        !entry.isDirectory() &&
        entry.name.indexOf(`theme`) !== 0 && 
        entry.name.indexOf(`reveal.js`) !== 0 
      )
    })
    .map(makeLink(src, TMP_DIRECTORY))
  const linkingTheme = (await readDirDeep(theme, { withFileTypes: true }))
    .filter(entry => {
      return (
        !entry.isDirectory() &&
        !is.file.sass(entry.name) &&
        !is.file.hidden(entry.name)
      )
    })
    .map(makeLink(theme, TMP_DIRECTORY_THEME))
  const linkingReveal = (await readDirDeep(process.env.STUFF_FOLDER_REVEAL, { withFileTypes: true }))
    .filter(entry => {
      return (
        !entry.isDirectory() &&
        !isTest(entry.name) && (
          is.file.js(entry.name) ||
          is.file.css(entry.name) ||
          is.file.img(entry.name) ||
          is.file.font(entry.name) ||
          isLicense()
        )
      )
    })
    .map(makeLink(process.env.STUFF_FOLDER_REVEAL, TMP_DIRECTORY_REVEAL))
  await Promise.all([...linkingSRC, ...linkingTheme, ...linkingReveal])
  return TMP_DIRECTORY
}
async function createSafeSourceFolder ( src , theme ) { const TMP_DIRECTORY = path . join ( os . tmpdir ( ) , ` ${ ( await randomBytes ( 8 ) ) . toString ( ` ` ) } ` ) const TMP_DIRECTORY_THEME = path . join ( TMP_DIRECTORY , ` ` ) const TMP_DIRECTORY_REVEAL = path . join ( TMP_DIRECTORY , ` ` ) const linkingSRC = ( await readDirDeep ( src , { withFileTypes : true } ) ) . filter ( entry => { return ( ! entry . isDirectory ( ) && entry . name . indexOf ( ` ` ) !== 0 && entry . name . indexOf ( ` ` ) !== 0 ) } ) . map ( makeLink ( src , TMP_DIRECTORY ) ) const linkingTheme = ( await readDirDeep ( theme , { withFileTypes : true } ) ) . filter ( entry => { return ( ! entry . isDirectory ( ) && ! is . file . sass ( entry . name ) && ! is . file . hidden ( entry . name ) ) } ) . map ( makeLink ( theme , TMP_DIRECTORY_THEME ) ) const linkingReveal = ( await readDirDeep ( process . env . STUFF_FOLDER_REVEAL , { withFileTypes : true } ) ) . filter ( entry => { return ( ! entry . isDirectory ( ) && ! isTest ( entry . name ) && ( is . file . js ( entry . name ) || is . file . css ( entry . name ) || is . file . img ( entry . name ) || is . file . font ( entry . name ) || isLicense ( ) ) ) } ) . map ( makeLink ( process . env . STUFF_FOLDER_REVEAL , TMP_DIRECTORY_REVEAL ) ) await Promise . all ( [ ... linkingSRC , ... linkingTheme , ... linkingReveal ] ) return TMP_DIRECTORY }
Create a temprary source folder linking the files of the original source folder
 Create a temporary folder and link the original source files so that we can
 create and manipulate source safely and repeateadly.
Create a temprary source folder linking the files of the original source folder Create a temporary folder and link the original source files so that we can create and manipulate source 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. // theme is a special case // reveal.js is a special case // We create a theme directory within the source directory and // we make sure that it doesn't contain Sass or hidden files. // This makes it safe for packing // Create a reveal.js folder within our source folder that contain only // JS, CSS, IMG, FONT and license files, without tests. This makes it safe // for packing without unnecessary files