Пример #1
0
    function finish() {
        logger.task(`Delete log file: ${relativePath(logFile)}`);

        var results = logger.end();

        console.log(results.output);

        fs.writeFileSync(logFile, results.outputNoColor, { encoding: 'utf8' });

        if (results.warningCount) {
            console.log(chalk.red.bold(`Migration completed with warning(s):`));
        } else {
            console.log(chalk.green('Migration completed successfully!:'));
        }

        console.log(chalk.red.bold(`- ${results.warningCount} warning(s)`));
        console.log(chalk.yellow.bold(`- ${results.pendingTaskCount} remaining task(s)`));
    }
Пример #2
0
 it('wraps a long string containing ansi chars', () => {
   const string = `abcde ${chalk.red.bold('red-bold')} 1234456` +
     `${chalk.dim('bcd')} ` +
     `123ttttttththththththththththththththththththththth` +
     `tetetetetettetetetetetetetete${chalk.underline.bold('stnhsnthsnth')}` +
     `ssot`;
   expect(wrapAnsiString(string, 10)).toMatchSnapshot();
   expect(stripAnsi(wrapAnsiString(string, 10))).toMatchSnapshot();
 });
Пример #3
0
function percentChange(prev, current) {
  const change = Math.floor((current - prev) / prev * 100);

  if (change > 0) {
    return chalk.red.bold(`+${change} %`);
  } else if (change <= 0) {
    return chalk.green.bold(change + ' %');
  }
}
Пример #4
0
 function reportStatus({ stdout, stderr }) {
     console.log(chalk.red.bold("Output:"))
     console.log(stdout)
     if (stdout !== "store.count: 0\nstore.count: 1\nstore.count: 0\n") {
         return Promise.reject("Stdout from test program was not as expected:\n\n" + stdout)
     }
     console.log(chalk.green("Success"))
     return Promise.resolve()
 }
Пример #5
0
exec(`git pull ${selectedVariant.git} ${selectedVariant['git-branch']}`, (code) => {
    clearInterval(interval);
    logUpdate.clear();
    if (code !== 0) {
        console.log(chalk.red.bold('Error! Try again'));
        exit(1);
    }
    console.log(chalk.green.bold('Completed.....You are good to go!'));
});
Пример #6
0
 webpack(config, (err, stats) => {
   if (err) {
     console.log(chalk.red.bold('Failed to create a production build!'));
     console.log(chalk.red(err.message || err));
     process.exit(1);
   }
   reportBuildStats(stats);
   console.log(chalk.green.bold('Compiled successfully!'));
 });
Пример #7
0
  fs.appendFile(__dirname + '/../app.log', entry, function(error) {
    if (error) {
      console.log(chalk.red(JSON.stringify(error)));
    }

    if (severity == "ERROR") {
      console.log(chalk.red.bold('Error logged'));
    }
  })
Пример #8
0
function error(error) {
    error = error.stack || error.toString();
    if (error.toUpperCase().indexOf('ERROR: ') === 0) {
        error = error.slice(7);
    }
    console.log(chalk.red.bold('SIM ERROR: ' + error));
    config.server && config.server.close();
    process.exit(1);
}
Пример #9
0
 req('get', "https://registry.npmjs.org/smelt-cli", function(err, res) {
     if (err) return;
     try { uv = res.body['dist-tags'].latest; } catch(e) {return;}
     if (cv !== uv)
     {
         console.log(chalk.red.bold("\n  [WARNING]: Your verion of Smelt (" + cv + ") is out of date. Please update to version " + uv + ".")); 
         console.log("  Command to update: " + chalk.bold("npm install smelt-cli -g")); 
         console.log("  Check for more information: " + chalk.bold("http://smelt.gnasp.com/changenotes.html")); 
     }
 });
Пример #10
0
	process.on('uncaughtException', function(err) {
		console.log(chalk.red.bold('Error!'));
		
		if(err.stack)
			console.log(' ', chalk.red(err.stack));
		else
			console.log(' ', chalk.red(err.toString()));
		
		console.log('');
	});
  }, function (err, airlines) {
    if (err) {
      console.log(chalk.red.bgWhite("\ngetAllDestinations found an error %s"), err); // eslint-disable-line no-console
    }
    airlines.destinationsSaved = destinationsSaved;
    airlines.errors = errors;
    debug("You got %s destinations and %s errors", destinationsSaved, errors);
    callback(err, airlines);

  });
Пример #12
0
    it('should wrap ansi styling to the next line properly', function (done) {
      var testName = 'wrap-ansi-styles';
      var expected = yosay(chalk.red.bgWhite('Hi') + ' there, sir! ' + chalk.bgBlue.white('you are looking') + ' swell today!');

      fs.readFile(getFixturePath(testName), function (err, data) {
        assert.ifError(err);
        assert.equal(JSON.parse(data), expected);
        done();
      });
    });
Пример #13
0
export function clear():boolean {
  try {
    rimraf(path.join(getUserDataPath(), '*.json'));
    return true;
  }
  catch (e) {
    console.error(chalk.red.bold());
    return false;
  }
}
Пример #14
0
localtunnel(port, opts, (err, tunnel) => {
  if (err) {
    console.log(chalk.red.bold(err));
  } else {
    const sourceUrl = chalk.green.bold(tunnel.url);
    const destUrl = chalk.green.bold(`http://localhost:${port}`);

    console.log(`Tunnel open from ${sourceUrl} to ${destUrl}.`);
  }
});
Пример #15
0
yoyo.prototype._exit = function _exit() {
  this.insight.track('yoyo', 'exit');

  console.log(
      '\nBye from us! Chat soon.'
    + '\n'
    + '\n' + chalk.red.bold('The Yeoman Team')
    + '\n https://github.com/yeoman/yeoman#team'
    + '\n');
};
Пример #16
0
    it('should handle part ansi and part not-ansi', function (done) {
      var testName = 'half-ansi';
      var expected = yosay(chalk.red.bgWhite('Hi') + ' there, sir!');

      fs.readFile(getFixturePath(testName), function (err, data) {
        assert.ifError(err);
        assert.equal(JSON.parse(data), expected);
        done();
      });
    });
Пример #17
0
    it('should display ansi styling correctly', function (done) {
      var testName = 'ansi';
      var expected = yosay(chalk.red.bgWhite('Hi'));

      fs.readFile(getFixturePath(testName), function (err, data) {
        assert.ifError(err);
        assert.equal(JSON.parse(data), expected);
        done();
      });
    });
Пример #18
0
          KM.loginAndGetAccessToken({ username : username, password: password }, function(err) {
            if (err) {
              console.error(chalk.red.bold(err) + '\n');
              return retry();
            }
            KM.getBuckets(function(err, buckets) {
              if (err) {
                console.error(chalk.red.bold(err) + '\n');
                return retry();
              }

              if (buckets.length > 1) {
                console.log(chalk.bold('Bucket list'));

                var table = new Table({
                  style : {'padding-left' : 1, head : ['cyan', 'bold'], compact : true},
                  head : ['Bucket name', 'Plan type']
                });

                buckets.forEach(function(bucket) {
                  table.push([bucket.name, bucket.credits.offer_type]);
                });

                console.log(table.toString());

                (function retryInsertion() {
                  promptly.prompt('Type the bucket you want to link to: ', function(err, bucket_name) {
                    var target_bucket = null;

                    buckets.some(function(bucket) {
                      if (bucket.name == bucket_name) {
                        target_bucket = bucket;
                        return true;
                      }
                    });

                    if (target_bucket == null)
                      return retryInsertion();
                    linkOpenExit(target_bucket);
                  });
                })();
              }
              else {
                var target_bucket = buckets[0];
                console.log('Connecting local PM2 to Keymetrics Bucket [%s]', target_bucket.name);

                KMDaemon.launchAndInteract(cst, {
                  public_key : target_bucket.public_id,
                  secret_key : target_bucket.secret_id
                }, function(err, dt) {
                  linkOpenExit(target_bucket);
                });
              }
            });
          });
Пример #19
0
pagespeed(url, strategy, locale, filterThirdParty).then(response => {
  if (response.error && response.error.code === 400) {
    spinner.stop();
    logUpdate(
      chalk.red.bold(`Could not resolve the URL: ${chalk.blue.bold(url)}
Please, check the spelling or make sure is accessible.'`)
    );
  }

  let isToShowUsabilityScore = (strategy === 'mobile');

  let speedScore = response.ruleGroups.SPEED.score;

  let message;

  if (speedScore < 21) {
    message = chalk.red.bold(`${logSymbols.error} Score: ${speedScore}`);
  } else if (speedScore < 80) {
    message = chalk.yellow.bold(`${logSymbols.warning} Score: ${speedScore}`);
  } else {
    message = chalk.green.bold(`${logSymbols.success} Score: ${speedScore}`);
  }

  if (isToShowUsabilityScore) {
    let usabilityScore = response.ruleGroups.USABILITY.score;

    if (usabilityScore < 21) {
      message += chalk.red.bold(`
${logSymbols.success} Usability: ${usabilityScore}`
      );
    } else if (usabilityScore < 80) {
      message += chalk.yellow.bold(`
${logSymbols.success} Usability: ${usabilityScore}`);
    } else {
      message += chalk.green.bold(`
${logSymbols.success} Usability: ${usabilityScore}`);
    }
  }

  spinner.stop();
  logUpdate(message);
});
Пример #20
0
    return execa('git', ['status', '-sb']).then(result => {
        // match current branch with remote if exists
        let match = String(result.stdout).match(/^## (\S+)/)

        // no match -> something went wrong
        if (!match) {
            throw new Error(
                chalk.red(figures.warning) +
                chalk.red.bold(' Error fetching git branch info.')
            )
        }

        match = match[1].split('...')

        if (flags.force && match[0] !== 'master') {
            // Continue with --force if not on master
            console.log(
                chalk.red(figures.cross +' Continuing with branch "' + match[0] + '" (--force)')
            )
        } else {
            // No --force and not on master? -> error message
            if (match[0] !== 'master') {
                throw new Error(
                    chalk.red(figures.warning) +
                    chalk.red.bold(
                        ' You are currently not on branch "master" but on "' + match[0] + '". This is not recommended!')
                    + '\n  Use --force to continue anyway.'
                )
            }

            console.log(
                chalk.green(figures.tick) +
                chalk.dim(' You are on branch "master"')
            )
        }

        // return current branch name and remote name
        return {
            current: match[0],
            remote: match[1] ? match[1].trim().replace(/\0/g, '') : ''
        }
    })
  compiler.run((error, stats) => {
    let jsonStats = stats.toJson(),
        errorLength = chalk.red.bold(jsonStats.errors.length),
        warningLength = chalk.red.bold(jsonStats.warnings.length)

    if (error) {
      debug('Error has occured while compiling', error)
    }

    if (stats.hasErrors()) {
      debug(`There has been ${errorLength} errors while compiling`, jsonStats.errors)
    }
    else if (stats.hasWarnings()) {
      debug(`There are ${warningLength} warnings while compiling`, jsonStats.warnings)
    }
    else {
      debug('No warnings or errors while compiling')
      debug('Webpack build has successfully finished!')
    }
  })
Пример #22
0
gulp.task('dev:applystyles', function() {
  if (!fs.existsSync(distPath)) {
    process.stderr.write(chalk.red.bold('Error:') + ' Directory ' + distPath + ' does not exist. You probably installed library by cloning repository directly instead of NPM repository.\n');
    process.stderr.write('You need to run ' + chalk.green.bold('gulp build') + ' first\n');
    process.exit(1);
    return 1;
  }
  return gulp.src([distPath + '/css/*.css'])
    .pipe(styleguide.applyStyles())
    .pipe(gulp.dest(outputPath));
});
Пример #23
0
 .catch((err) => {
   this.log(
     `${chalk.red.bold('ERROR')} Something went wrong and your repo is` +
      ` probably in a bad state. Sorry.`
   );
   resolve({
     successful: [],
     skipped: [],
     didAbort: true,
   });
 });
Пример #24
0
export default function(type, data) {

  var errors = {
    missing: `Unable to locate file/folder ${data}:  path not found`,
    engine: `Render called before render engine was set`,
    middleware: `Cannot set middleware for route ${data}: route not defined`
  }

  throw new Error(chalk.red.bold(errors[type]))

}
Пример #25
0
  webpack(config, (err, stats) => {
    if (err) {
      console.log(chalk.red.bold('Failed to create a production build!'));
      console.log(chalk.red(err.message || err));
      process.exit(1);
    }

    if (stats.compilation.errors && stats.compilation.errors.length) {
      console.log(chalk.red.bold('Failed to create a production build!'));
      stats.compilation.errors.forEach(err => console.log(chalk.red(err.message || err)));
      process.exit(1);
    }

    const jsonStats = stats.toJson();
    const seconds = jsonStats.time / 1000;
    console.log('Duration: ' + seconds.toFixed(2) + 's');
    console.log();

    console.log(chalk.green.bold('Compiled successfully!'));
  });
Пример #26
0
function findBowerDirectory(cwd) {
  var directory = path.join(cwd, (bowerConfig.read(cwd).directory || 'bower_components'));

  if (!fs.existsSync(directory)) {
    console.log(chalk.red.bold('Cannot find where you keep your Bower packages.'));

    process.exit();
  }

  return directory;
}
Пример #27
0
/**
 *  Detect if the option -m is present in the command
 */
function _detectComment(argv){
  var comment = ''
  if(argv._.length == 1){
    if(argv.m && typeof argv.m == 'string') comment = argv.m
    else if (argv.message && typeof argv.message == 'string') comment = argv.message
    return comment
  } else {
    console.log(chalk.red.bold('Invalid command: use stamplay deploy -m "YOUR MESSAGE"'))
    process.exit(1)
  }
}
Пример #28
0
                client.repositories( function(err, data) {

                    if ( err ) {
                        console.log(chalk.red.bold('An error occurred: ' + err));
                    } else {
                        console.log(chalk.cyan.bold('Total Repositories: ' + data.length));
                    }

                    // Line break at the bottom
                    console.log();
                });
Пример #29
0
 rl.question("What is your API base URL? ", function(answer){
     if(answer.length > 0){
         baseURL = answer;
         console.log("");
         nameMethods()
     } else {
         console.log(chalk.red.bold('Emtpy url. Aborting!'));
         process.exit(1);
         rl.close();
     }
 });
Пример #30
0
 const printStat = (name, stat, threshold) => {
   let msg = sprintf('  %20s: %s%% %d/%d (%d skipped)', chalk.bold(name), chalk.bold(sprintf('%.2d', stat.pct)), stat.covered, stat.total, stat.skipped);
   if (threshold) {
     if (stat.pct < threshold) {
       msg = chalk.red.bold(msg);
     } else {
       msg = chalk.green(msg);
     }
   }
   console.log(msg);
 };