'use strict'

const FS = require('fs')
const Base = require('./base')

class GenericPlugin extends Base {
  constructor() {
    super()
    this.registerTag(['Compiler-Include'], function(name, value) {
      return new Promise(function(resolve, reject) {
        FS.readFile(value, function (err, data) {
          if (err) reject(err)
          else resolve(data.toString())
        })
      })
    })
    this.registerTag(['Compiler-Output'], function(name, value, options) {
      options.Output = value
    })
    this.registerTag(['Compiler-Compress', 'Compiler-Uglify'], function(name, value, options) {
      options.Uglify = value === 'true'
    })
    this.registerTag(['Compiler-Babel', 'Compiler-Transpile'], function(name, value, options) {
      options.Babel = value === 'true'
    })
  }
  compile(contents, options) {
    return this.executeTags(contents, options)
  }
}

module.exports = GenericPlugin

'use strict'

const FS = require('fs')
const Path = require('path')
const Base = require('./base')

class GenericPlugin extends Base {
  constructor() {
    super()
    this.registerTag(['Compiler-Include'], function(name, value) {
      return new Promise(function(resolve, reject) {
        FS.readFile(value, function (err, data) {
          if (err) reject(err)
          else resolve(data.toString())
        })
      })
    })
    this.registerTag(['Compiler-Output'], function(name, value, options) {
      options.Output = Path.resolve(options.internal.file.directory, value)
    })
    this.registerTag(['Compiler-Compress', 'Compiler-Uglify'], function(name, value, options) {
      options.Uglify = value === 'true'
    })
    this.registerTag(['Compiler-Babel', 'Compiler-Transpile'], function(name, value, options) {
      options.Babel = value === 'true'
    })
  }
  compile(contents, options) {
    return this.executeTags(contents, options)
  }
}

module.exports = GenericPlugin

Make output path relative of file path
:bug: Make output path relative of file path
