first ready to use implementation

This commit is contained in:
2017-03-05 18:29:46 +01:00
parent c231e14791
commit 69f8db0ea1
10 changed files with 1379 additions and 2 deletions

40
ts/index.ts Normal file
View File

@ -0,0 +1,40 @@
import * as plugins from './smartsass.plugins'
// interfaces
import { Result } from 'node-sass'
export interface ISmartsassConstructorOptions {
entryFilePath: string
}
export class Smartsass {
entryFilePath: string
constructor(optionsArg: ISmartsassConstructorOptions) {
this.entryFilePath = optionsArg.entryFilePath
}
/**
* renders the Smartsass classes' entryfile and returns result as string
*/
render() {
let done = plugins.smartq.defer<plugins.sass.Result>()
plugins.sass.render({
file: this.entryFilePath
}, function (err, result) {
if (err) {
console.log(err)
done.reject(err)
}
done.resolve(result)
})
return done.promise
}
/**
* renders and stores
*/
async renderAndStore (outputFilePath: string) {
let result = await this.render()
await plugins.smartfile.memory.toFs(result.css.toString(), outputFilePath)
}
}

10
ts/smartsass.plugins.ts Normal file
View File

@ -0,0 +1,10 @@
import 'typings-global'
import * as sass from 'node-sass'
import * as smartfile from 'smartfile'
import * as smartq from 'smartq'
export {
sass,
smartfile,
smartq
}