index.js
function writeAndRunCodeBlocks(codeBlocks) {
  var dir = '.runnable-markdown-' + rand.generateKey(7);
  return makeTempDir(dir)
  .then(function() {
    return new Promise(function(fulfill, reject) {
      async.mapSeries(codeBlocks, function(codeBlock, callback) {
        appendCodeBlockToFile(codeBlock, dir)
          .then(runCodeBlock)
          .then(function(codeBlock) {
            callback(null, codeBlock);
          })
          .catch(function(err) {
            callback(err, null);
          });
      }, convertAsyncResultToPromise(fulfill, reject));
    });
  })
  .then(function(codeBlocks) {
    return removeOldDir(dir)
      .then(function() {
        return codeBlocks;
      });
  });
}
function writeAndRunCodeBlocks(codeBlocks) {
  var dir = '.runnable-markdown-' + rand.generateKey(7);
  return makeTempDir(dir)
  .then(function() {
    return new Promise(function(fulfill, reject) {
      async.mapSeries(codeBlocks, function(codeBlock, callback) {
        appendCodeBlockToFile(codeBlock, dir)
          .then(runCodeBlock)
          .then(function(codeBlock) {
            callback(null, codeBlock);
          })
          .catch(function(err) {
            callback(err, null);
          });
      }, convertAsyncResultToPromise(fulfill, reject));
    });
  })
  .then(function(codeBlocks) {
    return removeOldDir(dir)
      .then(function() {
        return codeBlocks;
      });
  });
}
function writeAndRunCodeBlocks ( codeBlocks ) { var dir = '.runnable-markdown-' + rand . generateKey ( 7 ) ; return makeTempDir ( dir ) . then ( function ( ) { return new Promise ( function ( fulfill , reject ) { async . mapSeries ( codeBlocks , function ( codeBlock , callback ) { appendCodeBlockToFile ( codeBlock , dir ) . then ( runCodeBlock ) . then ( function ( codeBlock ) { callback ( null , codeBlock ) ; } ) . catch ( function ( err ) { callback ( err , null ) ; } ) ; } , convertAsyncResultToPromise ( fulfill , reject ) ) ; } ) ; } ) . then ( function ( codeBlocks ) { return removeOldDir ( dir ) . then ( function ( ) { return codeBlocks ; } ) ; } ) ; }
Returns the same list of code blocks as what is passed in, but each filename includes the directory where it is stored.
Returns the same list of code blocks as what is passed in but each filename includes the directory where it is stored .