Skip to content
Branch: master
Find file History
Latest commit ff8ea5d Jun 17, 2019

writing a detector

  • write as many checks as possible to fit your project
  • return false if its not your project
  • if it definitely is, return an object with this shape:
    type: String, // e.g. gatsby, vue-cli
    command: String, // e.g. yarn, npm
    port: Number, // e.g. 8888
    proxyPort: Number, // e.g. 3000
    env: Object, // env variables, see examples
    possibleArgsArrs: [[String]], // e.g [['run develop]], so that the combined command is 'npm run develop', but we allow for multiple
    urlRegexp: RegExp, // see examples
    dist: String, // static folder where a _redirect file would be placed, e.g. 'public' or 'static'. NOT the build output folder

things to note

  • Dev block overrides will supercede anything you write in your detector:
  • detectors are language agnostic. don't assume npm or yarn.
  • if default args (like 'develop') are missing, that means the user has configured it, best to tell them to use the -c flag.

detector notes

not sure if we want to support gitbook yet

requires a global install:

const {
} = require("./utils/jsdetect");
module.exports = function() {
  if (!hasRequiredFiles(["", ""])) return false;
  // if (!hasRequiredDeps(["hexo"])) return false;

  /** everything below now assumes that we are within gatsby */

  const possibleArgsArrs = [["gitbook", "serve"]];
  // scanScripts({
  //   preferredScriptsArr: ["start", "dev", "develop"],
  //   preferredCommand: "hexo server"
  // });

  return {
    type: "gitbook",
    command: getYarnOrNPMCommand(),
    port: 8888,
    proxyPort: 4000,
    env: { ...process.env },
    urlRegexp: new RegExp(`(http://)([^:]+:)${4000}(/)?`, "g"),
    dist: "public"
You can’t perform that action at this time.