Skip to content
Browse files

Ported npm package shell script over to ant

    Removed the npm package shell script and
    moved it to an ant task in order to support
    building the package on windows.
  • Loading branch information...
1 parent a2430d0 commit bd5a99f6ae8a709127bdc410a72f1be590af9e51 @davglass committed Jan 11, 2012
Showing with 40 additions and 37 deletions.
  1. +1 −1 src/yui/Makefile
  2. +1 −0 src/yui/npm.properties
  3. +30 −0 src/yui/npm.xml
  4. +8 −6 src/yui/scripts/npm_package.js
  5. +0 −30 src/yui/scripts/npm_package.sh
View
2 src/yui/Makefile
@@ -12,4 +12,4 @@ docmods:
./scripts/build_doc_modules.js
npm:
- ./scripts/npm_package.sh
+ ant -f npm.xml
View
1 src/yui/npm.properties
@@ -0,0 +1 @@
+outdir=../../../yui-npm
View
30 src/yui/npm.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="npm" default="package">
+ <description>YUI NPM Build</description>
+ <property file="npm.properties" />
+
+ <echo level="info">Packaging YUI for npm deployment</echo>
+ <echo level="info">Using outdir: ${outdir}</echo>
+ <target name="package">
+ <echo level="info">Making outdir: ${outdir}</echo>
+ <delete dir="${outdir}" />
+ <mkdir dir="${outdir}" />
+
+ <echo level="info">Copying files to build location</echo>
+ <copy todir="${outdir}" overwrite="true">
+ <fileset dir="../../build/" />
+ </copy>
+
+ <copy file="../../package.json" tofile="${outdir}/package.json"/>
+ <copy file="./scripts/npm_package_shim.js" tofile="${outdir}/package.js"/>
+
+ <echo level="info">Running Node.js package script</echo>
+ <exec executable="node" failonerror="true" searchpath="true" resolveexecutable="true">
+ <arg value="./scripts/npm_package.js"/>
+ <arg value="${outdir}"/>
+ </exec>
+
+ <echo level="info">NPM package complete: ${outdir}</echo>
+ </target>
+
+</project>
View
14 src/yui/scripts/npm_package.js
@@ -9,7 +9,7 @@ var fs = require('fs'),
YUI.Env.core = [];
Y = YUI(); //This makes YUI.Env.aliases valid
-console.log('Prepping release for npm');
+console.error('Prepping release for npm');
var start = process.argv[2];
@@ -18,6 +18,8 @@ if (!start) {
process.exit(1);
}
+start = path.resolve(start);
+
if (!path.existsSync(start)) {
console.error('Out directory does not exist, exiting..');
process.exit(1);
@@ -46,7 +48,7 @@ var makeDebug = function(mod, p) {
return str;
};
-console.log('Writing index.js files');
+console.error('Writing index.js files');
var dirs = fs.readdirSync(start);
dirs.forEach(function(mod) {
var p = path.join(start, mod, 'index.js');
@@ -57,9 +59,9 @@ dirs.forEach(function(mod) {
fs.writeFileSync(d, makeDebug(mod), 'utf8');
}
});
-console.log('Index files written');
+console.error('Index files written');
-console.log('Writing seed debug file');
+console.error('Writing seed debug file');
var index = 'exports.path = function() {' +
' return __dirname;' +
'};\n' +
@@ -70,11 +72,11 @@ var index = 'exports.path = function() {' +
var p = path.join(start, 'debug.js');
fs.writeFileSync(p, index, 'utf8');
-console.log('Writing alias files');
+console.error('Writing alias files');
Object.keys(YUI.Env.aliases).forEach(function(mod) {
var index = makeIndex(mod, true);
var p = path.join(start, mod + '.js');
fs.writeFileSync(p, index, 'utf8');
});
-console.log('NPM Release Ready');
+console.error('NPM Release Ready');
View
30 src/yui/scripts/npm_package.sh
@@ -1,30 +0,0 @@
-#!/bin/bash
-
-cd "$(dirname "$0")"
-
-out=$1
-
-if [ ! -d "$out" ]; then
- out=/tmp/npm-yui/
- echo "Build directory not found using default: ${out}"
-fi
-
-echo "Using ${out} as build directory"
-
-if [ -d $out ]; then
- echo "Old build dir found, removing.."
- rm -rRf $out
-fi
-
-echo "Creating build dir"
-mkdir $out
-
-echo "Copying files to build location"
-cp -R ../../../build/* $out
-wait
-cp ../../../package.json "$out/package.json"
-wait
-cp ./npm_package_shim.js "$out/package.js"
-wait
-echo "Copy complete, running prep"
-./npm_package.js $out

0 comments on commit bd5a99f

Please sign in to comment.
Something went wrong with that request. Please try again.