Coder Social home page Coder Social logo

code-challenge's Introduction

Code Challenge

NPM version Build status Test coverage Greenkeeper badge

Install, run and share command line challenges. Perfect for learning, practicing or teaching others how to code.

Installation

You will need to install node.js. Once done, you can use npm to install the module globally and use the command line interface.

npm install -g code-challenge

Usage

challenge select   # Select a challenge to use
challenge exercise # Select an exercise to run

challenge print         # Print the currently selected exercise
challenge run [args]    # Run your solution in a test environment
challenge verify [args] # Check your solution is correct

challenge help  # Help menu
challenge reset # Reset everything

challenge next # Move to the next exercise
challenge prev # Move to the previous exercise

To get started, try installing your first challenge. I'd recommend Project Euler using npm install -g code-challenge-euler.

Create Your Own Challenge

To create a custom challenge pack to share, you'll need to create a new npm module and add code-challenge as a dependency. The module name must be prefixed with code-challenge- to automatically be loaded. The modules main file should require code-challenge, set the challenge title and add exercises.

var assert    = require('assert');
var challenge = require('code-challenge');

challenge.title = 'Example Challenge';

challenge.exercise('First Exercise')
  .add('print', function () {
    return challenge.renderFile(__dirname + '/exercises/01.md');
  })
  .add('verify', function () {
    return challenge.execFile(this._[0])
      .spread(function (stdout) {
        assert.equal(stdout, 'Example output\n');
      });
  });

...

challenge.exercise('Tenth Exercise')
  .add('print', ...)
  .add('verify', ...);

Rendering Any File

Challenge comes with a renderFile method that supports rending content from a file with standard syntax highlighting and colours.

Executing Any File

Challenge support executing most programming languages based on the file name automatically. By using the execFile or spawnFile methods, your challenge will be future proof and support all possible languages.

Failing an Exercise

When running the verification task, you can throw an error, reject a promise, error in a stream or pass an error as the first parameter of the callback to provide feedback.

Inspiration

Code challenge was originally inspired by all the work put into learnyounode, stream-adventure and gulp.

License

MIT

code-challenge's People

Contributors

blakeembrey avatar greenkeeper[bot] avatar orthographic-pedant avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.