Skip to content

Commit

Permalink
updating windows config instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
zetlen committed Oct 13, 2014
1 parent 02e7747 commit cfc5857
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ Installation:

Usage:

C:/some/long/path/> fenestrate make ./module
C:\some\long\path> fenestrate make .\module

(Of course it works on *nix systems as well.)

Commands:

Expand All @@ -44,4 +45,38 @@ You must always give fenestrate a path. It can be an absolute or relative
path, but it will never assume you should use the working directory, since
its operations can be (reversibly) destructive.

<!-- cut here -->

packaging
---------

If you're making an npm package and you know the graph is dangerously deep for windows (i'm looking at you, [bower](http://bower.io)) you should run `fenestrate make` on your package and commit the change.

The `fenestrate make` command creates a flatter dependency graph and saves it in a special `__fenestrate` attribute in your `package.json` file. By itself, it doesn't flatten the dep graph, but *indicates to the Windows consumer that the package can be safely flattened with `fenestrate rewrite`, and describes the flatter dependencies.* The idea is for Windows servers to add a post-install hook script to the `node_modules` folder in their installation root (and this setup is covered in the next section).

So by successfully running `fenestrate make` on your package before you publish it, you're letting Windows consumers know that your package is optimized for Windows, even if you can't test on Windows yourself.

windows server setup
--------------------

You can configure a Windows server to run `fenestrate rewrite` on every npm package that installs inside a certain directory tree. (Note that `fenestrate rewrite` will silently fail with a successful exit code if it doesn't find a `__fenestrate` configuration, so it can be safely run on non-fenestrated packages as well.)

Let's say that all of your npm packages on a given server will be descendents of the `D:\web\` folder. Add the following file, creating directories if they don't already exist:

D:\web\node_modules\.hooks\install.cmd

And put in that file:

fenestrate rewrite .

Add another, blank file, with the same name without the three-letter extension. (This is a Node quirk on Windows, to force it to acknowledge an install hook script.)

D:\web\node_modules\.hooks\install

Finally, install fenestrate globally:

npm install -g fenestrate

And now, all packages will be fenestrate rewritten as they come in. You're welcome.

Licensed GPLv3.
9 changes: 5 additions & 4 deletions fenestrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var fs = require('fs'),
cmdArgs = process.argv.slice(2),
cmd = cmdArgs.shift(),
modulePath = cmdArgs.shift(),
helpText = fs.readFileSync(path.resolve(__dirname, './README.md'), 'utf-8'),
helpText = fs.readFileSync(path.resolve(__dirname, './README.md'), 'utf-8').split('<!-- cut here -->').shift(),
dependencyTypes = ["dependencies","devDependencies"];

if (cmd === "help" || cmd === "-h" || !cmd) {
Expand Down Expand Up @@ -148,15 +148,16 @@ var commands = {

if (prod) dependencyTypes.pop();

if (!restore && f.previous) {
if (f && !restore && f.previous) {
console.log('This package is already in a transformed state. Run `fenestrate restore` before running `fenestrate rewrite` again.')
process.exit(0);
}
if (restore && !f.previous) {
if (f && restore && !f.previous) {
die('This package is not in a transformed state and cannot be restored.')
}
if (!f || !f[rewriteFrom]) {
die('A ' + rewriteFrom + ' configuration was never added to this package. Run `fenestrate make` and `fenestrate rewrite` before this command.');
console.log('A ' + rewriteFrom + ' configuration was never added to this package.');
process.exit(0);
}
f[saveTo] = {};
dependencyTypes.forEach(function(type) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "fenestrate",
"author": "James Zetlen",
"description": "Flatten the dependency tree of an NPM module so it can fit into the Windows 260-character path limitation.",
"version": "0.1.0",
"version": "0.1.1",
"bin": {
"fenestrate": "./bin/fenestrate"
},
Expand Down

0 comments on commit cfc5857

Please sign in to comment.