File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const throwError = require('./throwError')
88const paths = require ( './paths' )
99const sa = require ( 'sanitization' )
1010const semver = require ( 'semver' )
11+ const { version : miliVersion } = require ( '../package.json' )
1112
1213
1314// const readdir = promisify(fs.readdir)
@@ -68,6 +69,24 @@ module.exports = async templatePath => {
6869 throwError ( 'Template configuration error' )
6970 }
7071
72+ if ( config . engines && semver . validRange ( config . engines ) ) {
73+ if ( ! semver . satisfies ( miliVersion , config . engines ) ) {
74+ if ( semver . ltr ( miliVersion , config . engines ) ) {
75+ throwError ( [
76+ 'Your mili version is lower than the minimum version required by the template.' ,
77+ 'Please upgrade the mili version first.' ,
78+ `Mili version range:${ config . engines } ` ,
79+ ] . join ( '\n' ) )
80+ } else {
81+ throwError ( [
82+ 'Your mili version is higher than the maximum version required by the template.' ,
83+ 'Please downgrade the mili version first.' ,
84+ `Mili version range:${ config . engines } ` ,
85+ ] . join ( '\n' ) )
86+ }
87+ }
88+ }
89+
7190 config . rules = config . rules
7291 . map ( rule => {
7392 rule . path = join ( templatePath , config . path , rule . path )
You can’t perform that action at this time.
0 commit comments