Skip to content

Commit a73a780

Browse files
authored
Throw a waring when outFolder isn't defines in scully.config.js (#67)
* replaces require with custom one, and added node's global to context * throw waring when outfolder isn't in scully.config
1 parent f355610 commit a73a780

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

scully.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/** load the plugin */
2-
const {extraRoutesPlugin} = require('./extraPlugin/extra-plugin.js')
2+
const {extraRoutesPlugin} = require('./extraPlugin/extra-plugin.js');
33
/** register the plugin */
44
registerPlugin('router', 'extra', extraRoutesPlugin);
55

6-
76
exports.config = {
87
/** projectRoot is mandatory! */
98
projectRoot: './projects/sampleBlog/src/app',
9+
/** outFolder is where the static distribution files end up */
10+
outFolder: './dist/static',
1011

1112
routes: {
1213
'/demo/:id': {

scully/scully.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ let _options = {};
7878
spawn('node', [join(scullyConfig.homeFolder, './node_modules/.bin/scully'), 'serve'], {
7979
detached: true,
8080
}).on('close', err => {
81-
console.log(err);
8281
if (+err > 0) {
8382
spawn(
8483
'node',

scully/utils/config.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {jsonc} from 'jsonc';
33
import {join} from 'path';
44
import {findAngularJsonPath} from './findAngularJsonPath';
55
import {ScullyConfig} from './interfacesandenums';
6-
import {logError} from './log';
6+
import {logError, logWarn, yellow} from './log';
77
import {validateConfig} from './validateConfig';
88
import {compileConfig} from './compileConfig';
99

@@ -45,17 +45,24 @@ const loadIt = async () => {
4545
distFolder,
4646
appPort: /** 1864 */ 'herodevs'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
4747
staticport: /** 1771 */ 'scully'.split('').reduce((sum, token) => (sum += token.charCodeAt(0)), 1000),
48-
},
49-
await updateScullyConfig(compiledConfig)
48+
}
5049
// compiledConfig
5150
) as ScullyConfig;
51+
await updateScullyConfig(compiledConfig);
5252
return scullyConfig;
5353
};
5454
export const loadConfig = loadIt();
5555

5656
export const updateScullyConfig = async (config: Partial<ScullyConfig>) => {
5757
/** note, an invalid config will abort the entire program. */
5858
const newConfig = Object.assign({}, scullyConfig, config);
59+
if (config.outFolder === undefined) {
60+
logWarn(
61+
`The option outFolder isn't configures, we are using "${yellow(scullyConfig.outFolder)} by default now"`
62+
);
63+
} else {
64+
config.outFolder = join(angularRoot, config.outFolder);
65+
}
5966
const validatedConfig = await validateConfig(newConfig as ScullyConfig);
6067
if (validatedConfig) {
6168
const mergedRoutes = {...scullyConfig.routes, ...validatedConfig.routes};

0 commit comments

Comments
 (0)