Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
build creates release.zip
Browse files Browse the repository at this point in the history
  • Loading branch information
duncansmart committed Nov 11, 2013
1 parent a2bf34a commit d2dba4f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/bin/node_modules
/bin/node.exe
release.zip
54 changes: 30 additions & 24 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
@echo off
pushd "%~dp0\bin"

:: create httpget.js for use with cscript.exe
set HTTPGET_JS="%TEMP%\httpget.js"
echo (function(b,d){var a=b.Arguments(0);var c=b.Arguments(1);var f=new d("MSXML2.XMLHTTP");f.open("GET",a,false);f.send();if(f.Status==200){var e=new d("ADODB.Stream");e.Open();e.Type=1;e.Write(f.ResponseBody);e.Position=0;e.SaveToFile(c);e.Close()}else{b.Echo("Error: HTTP "+f.status+" "+f.statusText)}})(WScript,ActiveXObject); > %HTTPGET_JS%

:: Update node.exe
if not exist node.exe (
cscript //nologo %HTTPGET_JS% http://nodejs.org/dist/latest/node.exe node.exe
echo Downloading latest node.exe
cscript //nologo "%~dp0\tools\httpget.js" http://nodejs.org/dist/latest/node.exe node.exe
)

:: Install/Update less
:: Install/Update less (assumes npm is installed globally)
if exist "node_modules\less" (
call npm update less > nul 2>&1
echo Updating less
call npm update less --quiet
) else (
call npm install less > nul 2>&1
echo Installing less
call npm install less --quiet
)

:: Recursively grabs nested node_modules and moves them to the top level where
:: the require() algorithm will eventually find them. We do this because
:: node_modules can get nested beyond Win32's MAX_PATH 260 char limit.
:: Due to the way node_modues work, the directory depth can get very deep and go beyond MAX_PATH (260 chars).
:: Therefore grab all node_modues directories and move them up to baseNodeModuleDir. Node's require() will then
:: traverse up and find them at the higher level. Should be fine as long as there are no versioning conflicts.
:FLATTEN_NODE_MODULES
set BASE_MODULES=%~dp0node_modules
echo Flatenning node_modules
set BASE_MODULES=%~dp0bin\node_modules
pushd "%BASE_MODULES%"
for /l %%I in (1,1,3) do (
for /d /r %%D in (node_modules) do if exist %%D (
Expand All @@ -36,9 +36,10 @@ for /l %%I in (1,1,3) do (
)

:: clean varous junk directories from node_modules
:CLEAN_JS
:CLEAN_NODE_MODULES
echo Cleaning node_modules
for /d /r %%D in (*) do (
echo %%D
rem echo %%D
if "%%~nD"=="build" rd /s /q "%%D"
if "%%~nD"=="images" rd /s /q "%%D"
if "%%~nD"=="example" rd /s /q "%%D"
Expand All @@ -48,15 +49,20 @@ for /d /r %%D in (*) do (
if "%%~nD"=="tmp" rd /s /q "%%D"
if "%%~nD"=="man" rd /s /q "%%D"
)
:: various less junk
rd /s /q "less\.grunt"
rd /s /q "less\.idea"
rd /s /q "less\benchmark"
rd /s /q "less\dist"
rd /s /q "less\projectFilesBackup"

:: various less stuff we don't need to redistribute
rd /s /q "less\.grunt" 2>nul
rd /s /q "less\.idea" 2>nul
rd /s /q "less\benchmark" 2>nul
rd /s /q "less\dist" 2>nul
rd /s /q "less\projectFilesBackup" 2>nul

::tidy up
del %HTTPGET_JS%
:PACKAGE
echo Creating release.zip
set ZIP="%~dp0tools\7-zip\7za.exe"
set RELEASE_ZIP="%~dp0release.zip"
pushd "%~dp0"
if exist %RELEASE_ZIP% del %RELEASE_ZIP%
%ZIP% a %RELEASE_ZIP% bin\* -i!lessc.cmd -i!lessc-watch.cmd -i!LICENSE -i!README.md >nul
popd

popd
popd
Binary file added tools/7-zip/7za.exe
Binary file not shown.
29 changes: 29 additions & 0 deletions tools/7-zip/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
7-Zip Command line version
~~~~~~~~~~~~~~~~~~~~~~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7-Zip Copyright (C) 1999-2010 Igor Pavlov.

7za.exe is distributed under the GNU LGPL license

Notes:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.


GNU LGPL information
--------------------

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/
36 changes: 36 additions & 0 deletions tools/httpget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// httpget.js: download a file (Windows Script Host)
// usage: cscript httpget.js <url> <file>
// https://gist.github.com/duncansmart/5821523

(function() {
if (WScript.Arguments.Length != 2) {
WScript.Echo("Usage: httpget.js <url> <file>")
WScript.Quit(1)
}

var url = WScript.Arguments(0)
var filepath = WScript.Arguments(1)

var xhr = new ActiveXObject("MSXML2.XMLHTTP")

xhr.open("GET", url, false)
xhr.send()

if (xhr.Status == 200) {

var fso = new ActiveXObject("Scripting.FileSystemObject")
if (fso.FileExists(filepath))
fso.DeleteFile(filepath)

var stream = new ActiveXObject("ADODB.Stream")
stream.Open()
stream.Type = 1 //adTypeBinary
stream.Write(xhr.ResponseBody)
stream.Position = 0
stream.SaveToFile(filepath)
stream.Close()
}
else {
WScript.Echo("Error: HTTP " + xhr.status + " "+ xhr.statusText)
}
})();

0 comments on commit d2dba4f

Please sign in to comment.