New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

sourcefile

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

sourcefile

automatic sourcefile compiler for jade, stylus and coffeescript

unpublished
latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

source-file

source-file is a project to automatically recompile sourcefiles used during development. It exposes each file as an eventemitter that tells you when the file itself is loaded for the first time or if it is changed.

How to Install

npm install sourcefile

How to use

First, require sourcefile:

var Sourcefile = require('sourcefile');

Next, attach it to a sourcefile. First we show a jade-template:

// libs needed for the example
var fs    = require('fs'),
    jade  = require('jade');

// vars used
var Template = new Sourcefile('./index.jade'),
    template      = '';

Template.on('loaded', function(path) {
  fs.readFile(path, 'utf8', function(err, contents) {
    template = jade.compile(contents, {filename: path});
  });
});

Template.on('modified', function(path) {
  fs.readFile(path, 'utf8', function(err, contents) {
    template = jade.compile(contents, {filename: path});
  });
});

// Template.on('error', function(error) {}); 

Sugar

There are subclasses defined that will emit an compiled event. This will be called after these subclasses have done their job.

var template = '';
// This will identifiy the file as a jade file and use the callback accordingly
jadeTemplate = new Sourcefile.Jade('./index.jade');
jadeTemplate.on('compiled', function(data) {
  template = data;
});

Available are:

  • jade - Sourcefile.jade

    compiled jade template function

  • stylus - Sourcefile.stylus

    compiled stylus css as string

  • coffee-script - Sourcefile.coffee

    compiled coffee-script javascript code as string

var template = '';
// This will identifiy the file as a jade file and use the callback accordingly
Sourcefile.source('./index.jade', function(data) {
  template = data;
});

And for even more convenience or because its just stupid to sort everything again later we can tell the source-function what to use

// This will identifiy the file as a jade file and use the callback accordingly
// Here we will write the private `style.styl` to the public `style.css`
Sourcefile.source('./private/style.styl', ['coffee', 'stylus'], function(data, path, name) {
    fs.writeFile(name.replace('/private/', '/public/'), data, 'utf8');
});

FAQs

Package last updated on 29 Feb 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts