Skip to content

Commit

Permalink
Throw a waring when outFolder isn't defines in scully.config.js (#67)
Browse files Browse the repository at this point in the history
* replaces require with custom one, and added node's global to context
* throw waring when outfolder isn't in scully.config
  • Loading branch information
SanderElias authored Dec 20, 2019
1 parent f355610 commit a73a780
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions scully.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/** load the plugin */
const {extraRoutesPlugin} = require('./extraPlugin/extra-plugin.js')
const {extraRoutesPlugin} = require('./extraPlugin/extra-plugin.js');
/** register the plugin */
registerPlugin('router', 'extra', extraRoutesPlugin);


exports.config = {
/** projectRoot is mandatory! */
projectRoot: './projects/sampleBlog/src/app',
/** outFolder is where the static distribution files end up */
outFolder: './dist/static',

routes: {
'/demo/:id': {
Expand Down
1 change: 0 additions & 1 deletion scully/scully.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ let _options = {};
spawn('node', [join(scullyConfig.homeFolder, './node_modules/.bin/scully'), 'serve'], {
detached: true,
}).on('close', err => {
console.log(err);
if (+err > 0) {
spawn(
'node',
Expand Down
13 changes: 10 additions & 3 deletions scully/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {jsonc} from 'jsonc';
import {join} from 'path';
import {findAngularJsonPath} from './findAngularJsonPath';
import {ScullyConfig} from './interfacesandenums';
import {logError} from './log';
import {logError, logWarn, yellow} from './log';
import {validateConfig} from './validateConfig';
import {compileConfig} from './compileConfig';

Expand Down Expand Up @@ -45,17 +45,24 @@ const loadIt = async () => {
distFolder,
appPort: /** 1864 */ 'herodevs'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
staticport: /** 1771 */ 'scully'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
},
await updateScullyConfig(compiledConfig)
}
// compiledConfig
) as ScullyConfig;
await updateScullyConfig(compiledConfig);
return scullyConfig;
};
export const loadConfig = loadIt();

export const updateScullyConfig = async (config: Partial<ScullyConfig>) => {
/** note, an invalid config will abort the entire program. */
const newConfig = Object.assign({}, scullyConfig, config);
if (config.outFolder === undefined) {
logWarn(
`The option outFolder isn't configures, we are using "${yellow(scullyConfig.outFolder)} by default now"`
);
} else {
config.outFolder = join(angularRoot, config.outFolder);
}
const validatedConfig = await validateConfig(newConfig as ScullyConfig);
if (validatedConfig) {
const mergedRoutes = {...scullyConfig.routes, ...validatedConfig.routes};
Expand Down

0 comments on commit a73a780

Please sign in to comment.