Skip to content

Commit

Permalink
feat: consider more folders for node_modules location
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Dec 12, 2023
1 parent 08ec48e commit c66c9fc
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions extension/asset_platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,33 +190,27 @@ func InstallNodeModulesOfConfigs(cfgs ExtensionAssetConfig) ([]string, error) {

// Install shared node_modules between admin and storefront
for _, entry := range cfgs {
// Install also shared node_modules
if _, err := os.Stat(filepath.Join(entry.BasePath, "Resources", "app", "package.json")); err == nil {
npmPath := filepath.Join(entry.BasePath, "Resources", "app")
if err := installDependencies(npmPath); err != nil {
return nil, err
}

paths = append(paths, path.Join(npmPath, "node_modules"))
possibleNodePaths := []string{
// shared between admin and storefront
filepath.Join(entry.BasePath, "Resources", "app", "package.json"),
// only admin
filepath.Join(entry.BasePath, "Resources", "app", "administration", "package.json"),
filepath.Join(entry.BasePath, "Resources", "app", "administration", "src", "package.json"),

// only storefront
filepath.Join(entry.BasePath, "Resources", "app", "storefront", "package.json"),
filepath.Join(entry.BasePath, "Resources", "app", "storefront", "src", "package.json"),
}

if _, err := os.Stat(filepath.Join(entry.BasePath, "Resources", "app", "administration", "package.json")); err == nil {
npmPath := filepath.Join(entry.BasePath, "Resources", "app", "administration")
if err := installDependencies(npmPath); err != nil {
return nil, err
}

paths = append(paths, path.Join(npmPath, "node_modules"))
}
for _, possibleNodePath := range possibleNodePaths {
if _, err := os.Stat(possibleNodePath); err == nil {
npmPath := filepath.Dir(possibleNodePath)
if err := installDependencies(npmPath); err != nil {
return nil, err
}

if _, err := os.Stat(filepath.Join(entry.BasePath, "Resources", "app", "storefront", "package.json")); err == nil {
npmPath := filepath.Join(entry.BasePath, "Resources", "app", "storefront")
err := installDependencies(npmPath)
if err != nil {
return nil, err
paths = append(paths, path.Join(npmPath, "node_modules"))
}

paths = append(paths, path.Join(npmPath, "node_modules"))
}
}

Expand Down

0 comments on commit c66c9fc

Please sign in to comment.