Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configured for GitHub Releases and Travis CI.
- Loading branch information
Showing
8 changed files
with
132 additions
and
763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
node_modules/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: node_js | ||
node_js: | ||
- '0.10' | ||
before_install: | ||
- npm install coffee-script | ||
before_script: | ||
- ./node_modules/.bin/cake archive | ||
script: | ||
- ./node_modules/.bin/cake test | ||
deploy: | ||
provider: releases | ||
api_key: | ||
secure: by9x9mMPf7QcZEu1XsCCpTqM8CUgVs5+KZfmMNCE/bGuAn94pSdcKADiZFuQhRyJBiXT8V7yUOdeEtkgyhVNLfceoqStkWhFXWT1iILfiOzOrHsH2sjSfBFfvD2zAoAy7JBeqdiPbBsvuZfrdYS5QmZ654A6mHokeUnM0t42ePs= | ||
file: build/ObjCNSURLConnectionCodeGenerator.zip | ||
skip_cleanup: true | ||
on: | ||
tags: true | ||
all_branches: true | ||
repo: LuckyMarmot/Paw-ObjCNSURLConnectionCodeGenerator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,99 @@ | ||
{print} = require 'sys' | ||
{spawn} = require 'child_process' | ||
{ncp} = require 'ncp' | ||
mkdirp = require 'mkdirp' | ||
fs = require 'fs' | ||
|
||
file = 'ObjCNSURLConnectionCodeGenerator.coffee' | ||
identifier = 'com.luckymarmot.PawExtensions.ObjCNSURLConnectionCodeGenerator' | ||
|
||
task 'build', -> | ||
coffee = spawn 'coffee', ['-c', file] | ||
extensions_dir = "#{ process.env.HOME }/Library/Containers/com.luckymarmot.Paw/Data/Library/Application Support/com.luckymarmot.Paw/Extensions/" | ||
build_root_dir = "build" | ||
build_dir = "#{ build_root_dir }/#{ identifier }" | ||
|
||
# compile CoffeeScript | ||
build_coffee = (callback) -> | ||
coffee = spawn 'coffee', ['-c', '-o', build_dir, file] | ||
coffee.stderr.on 'data', (data) -> | ||
process.stderr.write data.toString() | ||
coffee.stdout.on 'data', (data) -> | ||
print data.toString() | ||
process.stdout.write data.toString() | ||
coffee.on 'exit', (code) -> | ||
if code is 0 | ||
console.log '>>> Build successful' | ||
callback?() | ||
else | ||
console.error "Build failed with error: #{ code }" | ||
|
||
# copy files to build directory | ||
build_copy = () -> | ||
fs.writeFileSync "#{ build_dir }/README.md", fs.readFileSync("./README.md") | ||
fs.writeFileSync "#{ build_dir }/LICENSE", fs.readFileSync("./LICENSE") | ||
fs.writeFileSync "#{ build_dir }/objc.mustache", fs.readFileSync("./objc.mustache") | ||
fs.writeFileSync "#{ build_dir }/mustache.js", fs.readFileSync("./node_modules/mustache/mustache.js") | ||
fs.writeFileSync "#{ build_dir }/URI.js", fs.readFileSync("./lib/URI.js") | ||
|
||
# build: build CoffeeScript and copy files to build directory | ||
build = (callback) -> | ||
# mkdir build dir | ||
mkdirp build_dir, (err) -> | ||
if err | ||
console.error err | ||
else | ||
console.log '!!! Build failed' | ||
build_coffee () -> | ||
build_copy() | ||
callback?() | ||
|
||
# install: copy files to Extensions directory | ||
install = (callback) -> | ||
ncp build_dir, "#{ extensions_dir }/#{ identifier }", (err) -> | ||
if err | ||
console.error err | ||
else | ||
callback?() | ||
|
||
# archive: create a zip archive from the build | ||
archive = (callback) -> | ||
zip_file = "#{ identifier.split('.').pop() }.zip" | ||
|
||
# go to build dir | ||
process.chdir "#{ build_root_dir }/" | ||
|
||
# delete any previous zip | ||
if fs.existsSync zip_file | ||
fs.unlinkSync zip_file | ||
|
||
# zip | ||
zip = spawn 'zip', ["-r", zip_file, "#{ identifier }/"] | ||
zip.stderr.on 'data', (data) -> | ||
process.stderr.write data.toString() | ||
zip.stdout.on 'data', (data) -> | ||
process.stdout.write data.toString() | ||
zip.on 'exit', (code) -> | ||
if code is 0 | ||
callback?() | ||
else | ||
console.error "zip returned with error code: #{ code }" | ||
|
||
task 'build', -> | ||
build() | ||
|
||
task 'test', -> | ||
build () -> | ||
# no test to run | ||
|
||
task 'install', -> | ||
build () -> | ||
install() | ||
|
||
task 'archive', -> | ||
build () -> | ||
archive() | ||
|
||
task 'watch', -> | ||
spawn 'coffee', ['--watch', '--compile', file] | ||
# find all files in directory | ||
for filename in fs.readdirSync '.' | ||
# only watch non-hidden files | ||
if not filename.match(/^\./) and fs.lstatSync("./#{ filename }").isFile() | ||
fs.watchFile "./#{ filename }", {persistent:true, interval:500}, (_event, _filename) -> | ||
# when a file is changed, build and install | ||
build () -> | ||
install() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.