scripts: normalize project path to be relative to root for npm start

This commit is contained in:
Chris Breiding
2017-06-13 13:50:51 -04:00
parent 4c87353c78
commit 6d3c5834f7
2 changed files with 15 additions and 0 deletions
+14
View File
@@ -1 +1,15 @@
const findIndex = require('lodash/findIndex')
const path = require('path')
// if passing the --project arg, normalize its value so that it's
// relative to the root and not to packages/server
const projectArgIndex = findIndex(process.argv, (arg) => arg === '--project')
if (projectArgIndex > -1) {
const projectPath = process.argv[projectArgIndex + 1]
// make sure it's the path and not another argument flag
if (projectPath.substring(0, 2) !== '--') {
process.argv[projectArgIndex + 1] = path.resolve(projectPath)
}
}
require('@packages/server')