diff --git a/bin/express-cli.js b/bin/express-cli.js index 380a447d..911b71a8 100755 --- a/bin/express-cli.js +++ b/bin/express-cli.js @@ -9,6 +9,7 @@ var path = require('path') var readline = require('readline') var sortedObject = require('sorted-object') var util = require('util') +var semver = require('semver') var MODE_0666 = parseInt('0666', 8) var MODE_0755 = parseInt('0755', 8) @@ -212,7 +213,15 @@ function createApplication (name, dir, options, done) { case 'sass': app.locals.modules.sassMiddleware = 'node-sass-middleware' app.locals.uses.push("sassMiddleware({\n src: path.join(__dirname, 'public'),\n dest: path.join(__dirname, 'public'),\n indentedSyntax: true, // true = .sass and false = .scss\n sourceMap: true\n})") - pkg.dependencies['node-sass-middleware'] = '0.11.0' + try { + if (semver.satisfies(process.version, '>=10.0.0')) { + pkg.dependencies['node-sass-middleware'] = '1.0.1' + } else { + throw new Error('node-sass-middleware version >=1.0 requires Node.js 10 or higher. Using Node.js 9 or lower.') + } + } catch (e) { + pkg.dependencies['node-sass-middleware'] = '0.11.0' + } break case 'stylus': app.locals.modules.stylus = 'stylus' diff --git a/package.json b/package.json index c8fb0b19..2bc2b344 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "minimatch": "3.0.4", "minimist": "1.2.5", "mkdirp": "0.5.1", + "semver": "5.5.0", "sorted-object": "2.0.1" }, "main": "bin/express-cli.js",