Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #446 from Shopify/fix-node-version-warning
Browse files Browse the repository at this point in the history
Fix Node version check and error
  • Loading branch information
t-kelly authored Mar 21, 2018
2 parents 6f7bedd + fa5c36a commit ae00874
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions packages/create-slate-theme/index.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
#!/usr/bin/env node
/* eslint-disable */

const chalk = require('chalk');
const program = require('commander');
const semver = require('semver');
const createSlateTheme = require('./create-slate-theme');
const packageJson = require('./package.json');
const config = require('./create-slate-theme.config');
/* This file must remain compatible for as many legacy versions of Node as possible. Avoid ES6+ language. */

const currentNodeVersion = process.versions.node;
var chalk = require('chalk');
var program = require('commander');
var semver = require('semver');
var packageJson = require('./package.json');
var config = require('./create-slate-theme.config');

var currentNodeVersion = process.versions.node;

if (!semver.satisfies(currentNodeVersion, '>=8.9.4')) {
console.log(
chalk.red(
`You are running Node ${currentNodeVersion}\n\`` +
`Create Slate Theme requires Node 8.9.4 or higher. \n` +
`Please update your version of Node.`,
),
'You are running Node ' +
currentNodeVersion +
'\n' +
'Create Slate Theme requires Node 8.9.4 or higher. \n' +
'Please update your version of Node.'
)
);

process.exit(1);
}

let themeName;
let themeStarter;
var themeName;
var themeStarter;

program
.version(packageJson.version)
.usage(`${chalk.green('<theme-directory>')} [starter-theme] [options]`)
.usage(chalk.green('<theme-directory>') + '[starter-theme] [options]')
.arguments('<name> [repo]')
.option('--skipInstall', 'skip installing theme dependencies')
.option('--ssh', 'uses SSH to clone git repo')
.option('--verbose', 'print additional logs')
.action((name, starter = config.defaultStarter) => {
.action((name, starter) => {
themeName = name;
themeStarter = starter;
themeStarter = starter || config.defaultStarter;
})
.parse(process.argv);

if (typeof themeName === 'undefined') {
console.error('Please specify the theme directory:');
console.log(
`${chalk.cyan(program.name())} ${chalk.green('<theme-directory>')}`,
`${chalk.cyan(program.name())} ${chalk.green('<theme-directory>')}`
);
console.log();
console.log('For example:');
console.log(`${chalk.cyan(program.name())} ${chalk.green('my-theme')}`);
console.log(chalk.cyan(program.name()) + ' ' + chalk.green('my-theme'));
console.log();
console.log(
`Run${chalk.cyan(`${program.name()} --help`)} to see all options.`,
'Run ' + chalk.cyan(program.name() + ' --help') + ' to see all options.'
);
process.exit(1);
}
Expand All @@ -58,9 +62,9 @@ function assignOption(key) {
: program[key];
}

const options = {
var options = {
skipInstall: assignOption('skipInstall'),
ssh: assignOption('ssh'),
};

createSlateTheme(themeName, themeStarter, options);
require('./create-slate-theme')(themeName, themeStarter, options);

0 comments on commit ae00874

Please sign in to comment.