mirror of https://github.com/databricks/cli.git
Error when file does not exist
This commit is contained in:
parent
c9340d6317
commit
c98671a08b
|
@ -3,7 +3,6 @@ package mutator
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -35,10 +34,6 @@ func (m *translateNotebookPaths) rewritePath(b *bundle.Bundle, p *string) error
|
|||
absPath := filepath.Join(b.Config.Path, relPath)
|
||||
nb, _, err := notebook.Detect(absPath)
|
||||
if err != nil {
|
||||
// Ignore if this file doesn't exist. Maybe it's an absolute workspace path?
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unable to determine if %s is a notebook: %w", relPath, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package notebook
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -39,6 +41,10 @@ func readHeader(path string) ([]byte, error) {
|
|||
func Detect(path string) (notebook bool, language workspace.Language, err error) {
|
||||
header := ""
|
||||
|
||||
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
|
||||
return false, "", fmt.Errorf("file %s does not exist", path)
|
||||
}
|
||||
|
||||
// Determine which header to expect based on filename extension.
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
switch ext {
|
||||
|
|
Loading…
Reference in New Issue