lib/square.js
function insert(match, commenttype, statement, file) {
    var location = path.resolve(reference, file)
      , data = '';

    //
    // If it's not an absolute path, try to require.resolve the file.
    //
    if (!fs.existsSync(location)) try {
      location = require.resolve(file);
    } catch (e) { }

    if (!fs.existsSync(location)) {
      return self.critical(
          '// [square] @%s statement %s in %s does not exist'
        , statement
        , file.red
        , reference.red
      );
    }

    if (~seen.indexOf(location)) {
      return self.critical('recursive [square] import statement detected %s', match);
    }

    // We processed the file, mark it as seen to protect us against recursive
    // includes.
    seen.push(location);

    data += self.commentWrap('[square] Directive: ' + location, extension);
    data += fs.readFileSync(location, 'utf8').trim();

    // Pass the contents back in to the directive again so we can also process
    // the directives inside the directive.
    return self.directive(data, extension, path.dirname(location), seen);
  }
function insert(match, commenttype, statement, file) {
    var location = path.resolve(reference, file)
      , data = '';

    //
    // If it's not an absolute path, try to require.resolve the file.
    //
    if (!fs.existsSync(location)) try {
      location = require.resolve(file);
    } catch (e) { }

    if (!fs.existsSync(location)) {
      return self.critical(
          '// [square] @%s statement %s in %s does not exist'
        , statement
        , file.red
        , reference.red
      );
    }

    if (~seen.indexOf(location)) {
      return self.critical('recursive [square] import statement detected %s', match);
    }

    // We processed the file, mark it as seen to protect us against recursive
    // includes.
    seen.push(location);

    data += self.commentWrap('[square] Directive: ' + location, extension);
    data += fs.readFileSync(location, 'utf8').trim();

    // Pass the contents back in to the directive again so we can also process
    // the directives inside the directive.
    return self.directive(data, extension, path.dirname(location), seen);
  }
function insert ( match , commenttype , statement , file ) { var location = path . resolve ( reference , file ) , data = '' ; // // If it's not an absolute path, try to require.resolve the file. // if ( ! fs . existsSync ( location ) ) try { location = require . resolve ( file ) ; } catch ( e ) { } if ( ! fs . existsSync ( location ) ) { return self . critical ( '// [square] @%s statement %s in %s does not exist' , statement , file . red , reference . red ) ; } if ( ~ seen . indexOf ( location ) ) { return self . critical ( 'recursive [square] import statement detected %s' , match ) ; } // We processed the file, mark it as seen to protect us against recursive // includes. seen . push ( location ) ; data += self . commentWrap ( '[square] Directive: ' + location , extension ) ; data += fs . readFileSync ( location , 'utf8' ) . trim ( ) ; // Pass the contents back in to the directive again so we can also process // the directives inside the directive. return self . directive ( data , extension , path . dirname ( location ) , seen ) ; }
Process the directive.

@param {String} match complete matched result
@param {String} commenttype type of comment
@param {String} statement import statement name
@param {String} file the file that needs to be inlined
@returns {String}
@api private
Process the directive .