Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Allow ng build to be un from any subfolder (#4422)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwmac committed Jul 7, 2020
1 parent 2227c5b commit 3daa32b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/frontend/packages/devkit/src/build/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ExtensionsHandler {
public apply(webpackConfig: any, config: StratosConfig, options: any) {

// Generate the module file to import the appropriate extensions
const dir = path.dirname(options.main);
const dir = path.join(config.rootDir, path.dirname(options.main));
const overrideFile = path.resolve(path.join(dir, './_custom-import.module.ts'));

fs.writeFileSync(overrideFile, '// This file is auto-generated - DO NOT EDIT\n\n');
Expand Down
15 changes: 9 additions & 6 deletions src/frontend/packages/devkit/src/lib/stratos.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export class StratosConfig implements Logger {
public nodeModulesFile: string;
public angularJsonFile: string;

public rootDir: string;

// angular.json contents
public angularJson: any;

Expand All @@ -44,6 +46,9 @@ export class StratosConfig implements Logger {
this.angularJson = JSON.parse(fs.readFileSync(this.angularJsonFile, 'utf8').toString());
this.loggingEnabled = loggingEnabled;

// Top-level folder
this.rootDir = path.dirname(this.angularJsonFile);

// The Stratos config file is optional - allows overriding default behaviour
this.stratosConfig = {};
if (this.angularJsonFile) {
Expand All @@ -65,22 +70,20 @@ export class StratosConfig implements Logger {
// Exclude the default packages... unless explicity `include`d
this.excludeExamples()

const mainDir = options ? path.dirname(options.main) : dir;

this.packageJsonFile = this.findFileOrFolderInChain(mainDir, 'package.json');
this.packageJsonFile = this.findFileOrFolderInChain(this.rootDir, 'package.json');
if (this.packageJsonFile !== null) {
this.packageJson = JSON.parse(fs.readFileSync(this.packageJsonFile, 'utf8').toString());
}

this.nodeModulesFile = this.findFileOrFolderInChain(mainDir, 'node_modules');
this.nodeModulesFile = this.findFileOrFolderInChain(this.rootDir, 'node_modules');

this.gitMetadata = new GitMetadata(path.dirname(this.angularJsonFile));
this.gitMetadata = new GitMetadata(this.rootDir);
// this.log(this.gitMetadata);
if (this.gitMetadata.exists) {
this.log('Read git metadata file');
}

this.newProjectRoot = this.angularJson.newProjectRoot;
this.newProjectRoot = path.join(this.rootDir, this.angularJson.newProjectRoot);

// Discover all packages

Expand Down

0 comments on commit 3daa32b

Please sign in to comment.