Skip to content

Commit ceee950

Browse files
committed
Improve how projectRoot is computed
1 parent 9384068 commit ceee950

File tree

12 files changed

+30
-84
lines changed

12 files changed

+30
-84
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
"postinstall": "node ./scripts/postinstall.js"
6464
},
6565
"dependencies": {
66-
"@netlify/build": "^2.0.20",
67-
"@netlify/config": "^1.2.5",
66+
"@netlify/build": "^2.0.21",
67+
"@netlify/config": "^2.0.0",
6868
"@netlify/zip-it-and-ship-it": "^1.3.1",
6969
"@oclif/command": "^1.5.18",
7070
"@oclif/config": "^1.13.2",

src/utils/command.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const { track, identify } = require('./telemetry')
77
const openBrowser = require('./open-browser')
88
const StateConfig = require('./state-config')
99
const globalConfig = require('./global-config')
10-
const findRoot = require('./find-root')
1110
const chalkInstance = require('./chalk')
1211
const resolveConfig = require('@netlify/config')
1312

@@ -23,19 +22,18 @@ class BaseCommand extends Command {
2322
super(...args)
2423
}
2524
// Initialize context
26-
async init(_projectRoot) {
25+
async init() {
2726
const cwd = argv.cwd || process.cwd()
28-
const projectRoot = findRoot(_projectRoot || cwd) // if calling programmatically, can use a supplied root, else in normal CLI context it just uses process.cwd()
2927
// Grab netlify API token
3028
const authViaFlag = getAuthArg(argv)
3129

3230
const [token] = this.getConfigToken(authViaFlag)
3331

3432
// Get site id & build state
35-
const state = new StateConfig(projectRoot)
33+
const state = new StateConfig(cwd)
3634

37-
const cachedConfig = await this.getConfig(cwd, projectRoot, state, token)
38-
const { configPath, config } = cachedConfig
35+
const cachedConfig = await this.getConfig(cwd, state, token)
36+
const { configPath, config, buildDir } = cachedConfig
3937

4038
const apiOpts = {}
4139
if (NETLIFY_API_URL) {
@@ -50,7 +48,7 @@ class BaseCommand extends Command {
5048
api: new API(token || '', apiOpts),
5149
// current site context
5250
site: {
53-
root: projectRoot,
51+
root: buildDir,
5452
configPath: configPath,
5553
get id() {
5654
return state.get('siteId')
@@ -71,12 +69,11 @@ class BaseCommand extends Command {
7169
}
7270

7371
// Find and resolve the Netlify configuration
74-
async getConfig(cwd, projectRoot, state, token) {
72+
async getConfig(cwd, state, token) {
7573
try {
7674
return await resolveConfig({
7775
config: argv.config,
7876
cwd: cwd,
79-
repositoryRoot: projectRoot,
8077
context: argv.context,
8178
siteId: state.get('siteId'),
8279
token,

src/utils/find-root/fixtures/git-project/some/sub/dir/.keep

Whitespace-only changes.

src/utils/find-root/fixtures/no-indicator/some/sub/dir/.keep

Whitespace-only changes.

src/utils/find-root/fixtures/state-folder/.netlify/.keep

Whitespace-only changes.

src/utils/find-root/fixtures/state-folder/some/sub/dir/.keep

Whitespace-only changes.

src/utils/find-root/fixtures/toml-config/netlify.toml

Whitespace-only changes.

src/utils/find-root/fixtures/toml-config/some/sub/dir/.keep

Whitespace-only changes.

src/utils/find-root/index.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)