How to use the @jscad/core/code-loading/requireDesignUtilsFs.getDesignEntryPoint function in @jscad/core

To help you get started, we’ve selected a few @jscad/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jscad / OpenJSCAD.org / packages / cli / cli.js View on Github external
} else if (args[i].match(/.+\.(jscad|js|scad|stl|amf|obj|gcode|svg|json)$/i)) {
      inputFile = args[i]
      inputFormat = RegExp.$1
      if (!fs.statSync(inputFile).isFile()) {
        console.log('ERROR: cannot open input file/directory <' + inputFile + '>')
        process.exit(1)
      }
    } else if (args[i].match(/^-v$/)) { // show the version and the environment information
      env()
      console.log('OpenSCAD Compatibility (' + version + ')')
    } else {
      inputFile = args[i]
      if (fs.statSync(inputFile).isDirectory()) {
        inputFile = args[i]
        // get actual design entry point if applicable (if passed a folder as input etc)
        inputFile = getDesignEntryPoint(inputFile)
        inputFormat = require('path').extname(inputFile).substring(1)
      } else {
        console.log('ERROR: invalid file name or argument <' + args[i] + '>')
        console.log("Type 'openjscad' for help")
        process.exit(1)
      }
    }
  }
  // exit if a input file was not provided
  if (inputFile === null) process.exit(1)

  if (!outputFormat && !outputFile) {
    outputFormat = 'stla'
  }

  return {
github jscad / jscad-desktop / src / ui / design / reducers.js View on Github external
const setDesignPath = (state, paths) => {
  // console.log('setDesignPath')
  const mainPath = getDesignEntryPoint(paths)
  const filePath = paths[0]
  const designName = getDesignName(paths)
  const designPath = path.dirname(filePath)

  const design = Object.assign({}, state.design, {
    name: designName,
    path: designPath,
    mainPath
  })

  // we want the viewer to focus on new entities for our 'session' (until design change)
  const viewer = Object.assign({}, state.viewer, {behaviours: {resetViewOn: ['new-entities']}})
  return Object.assign({}, state, {busy: true, viewer, design})
}
github jscad / OpenJSCAD.org / packages / web / src / ui / flow / design.js View on Github external
setDesignContent: (state, payload) => {
    console.log('design: set content', state, state.design, payload)
    // all our available data (specific to web)
    const { filesAndFolders } = payload
    const makeFakeFs = require('@jscad/core/code-loading/makeFakeFs')
    const fakeFs = makeFakeFs(filesAndFolders)
    const rootPath = filesAndFolders[0].fullPath
    const mainPath = getDesignEntryPoint(fakeFs, rootPath)
    const designName = getDesignName(fakeFs, rootPath)
    const designPath = path.dirname(rootPath)
    console.log('BLAA', rootPath, designName, designPath)

    let design = state.design
    // to track computation time
    const debug = Object.assign({ }, state.design.debug, { startTime: new Date() })

    design = Object.assign({}, design, {
      name: designName,
      path: designPath,
      mainPath,
      filesAndFolders,
      debug
    })