index.js
function updateCopyright(str, context, options) {
  if (typeof str !== 'string') {
    options = context;
    context = str;
    str = null;
  }

  var opts = utils.merge({template: template, copyright: ''}, options);
  var pkg = opts.pkg || utils.loadPkg.sync(process.cwd());
  var engine = new utils.Engine(opts);

  // create the template context from defaults, package.json,
  // context from parsing the original statement, and options.
  var ctx = utils.merge({}, defaults, pkg, context, opts);
  ctx.authors = ctx.author = author(ctx, pkg, options);
  ctx.years = ctx.year = updateYear(ctx);
  var statement = ctx.statement;

  // if no original statement was found, create one with the template
  if (typeof statement === 'undefined') {
    return engine.render(opts.template, ctx);
  }

  // necessary since the copyright regex doesn't match
  // the trailing dot. If it does later this is future-proof
  if (statement[statement.length - 1] !== '.') {
    var ch = statement + '.';
    if (str.indexOf(ch) !== -1) {
      statement = ch;
    }
  }

  // create the new copyright statement
  var newStatement = engine.render(opts.template, ctx);
  if (str == null) {
    return newStatement;
  }

  // if the original string is no more than a copyright statement
  // just return the new one
  if (statement.trim() === str.trim() || opts.statementOnly === true) {
    return newStatement;
  }

  return str.replace(statement, newStatement);
}
function updateCopyright(str, context, options) {
  if (typeof str !== 'string') {
    options = context;
    context = str;
    str = null;
  }

  var opts = utils.merge({template: template, copyright: ''}, options);
  var pkg = opts.pkg || utils.loadPkg.sync(process.cwd());
  var engine = new utils.Engine(opts);

  // create the template context from defaults, package.json,
  // context from parsing the original statement, and options.
  var ctx = utils.merge({}, defaults, pkg, context, opts);
  ctx.authors = ctx.author = author(ctx, pkg, options);
  ctx.years = ctx.year = updateYear(ctx);
  var statement = ctx.statement;

  // if no original statement was found, create one with the template
  if (typeof statement === 'undefined') {
    return engine.render(opts.template, ctx);
  }

  // necessary since the copyright regex doesn't match
  // the trailing dot. If it does later this is future-proof
  if (statement[statement.length - 1] !== '.') {
    var ch = statement + '.';
    if (str.indexOf(ch) !== -1) {
      statement = ch;
    }
  }

  // create the new copyright statement
  var newStatement = engine.render(opts.template, ctx);
  if (str == null) {
    return newStatement;
  }

  // if the original string is no more than a copyright statement
  // just return the new one
  if (statement.trim() === str.trim() || opts.statementOnly === true) {
    return newStatement;
  }

  return str.replace(statement, newStatement);
}
function updateCopyright ( str , context , options ) { if ( typeof str !== 'string' ) { options = context ; context = str ; str = null ; } var opts = utils . merge ( { template : template , copyright : '' } , options ) ; var pkg = opts . pkg || utils . loadPkg . sync ( process . cwd ( ) ) ; var engine = new utils . Engine ( opts ) ; // create the template context from defaults, package.json, // context from parsing the original statement, and options. var ctx = utils . merge ( { } , defaults , pkg , context , opts ) ; ctx . authors = ctx . author = author ( ctx , pkg , options ) ; ctx . years = ctx . year = updateYear ( ctx ) ; var statement = ctx . statement ; // if no original statement was found, create one with the template if ( typeof statement === 'undefined' ) { return engine . render ( opts . template , ctx ) ; } // necessary since the copyright regex doesn't match // the trailing dot. If it does later this is future-proof if ( statement [ statement . length - 1 ] !== '.' ) { var ch = statement + '.' ; if ( str . indexOf ( ch ) !== - 1 ) { statement = ch ; } } // create the new copyright statement var newStatement = engine . render ( opts . template , ctx ) ; if ( str == null ) { return newStatement ; } // if the original string is no more than a copyright statement // just return the new one if ( statement . trim ( ) === str . trim ( ) || opts . statementOnly === true ) { return newStatement ; } return str . replace ( statement , newStatement ) ; }
Update an existing copyright statement, or create a new one
if one isn't passed.

@param {String} `str` String with copyright statement
@param {Object} `context` Context to use for rendering the copyright template
@param {Object} `options`
@return {String}
Update an existing copyright statement or create a new one if one isn t passed .