diff --git a/Makefile b/Makefile index bc44701c..503171a3 100644 --- a/Makefile +++ b/Makefile @@ -4,45 +4,16 @@ # -PACKAGE_NAME = markdown-here -MOZILLA_PACKAGE_NAME = $(PACKAGE_NAME)-mozilla.xpi -CHROME_PACKAGE_NAME = $(PACKAGE_NAME)-chrome.zip -POSTBOX_PACKAGE_NAME = $(PACKAGE_NAME)-postbox.xpi DIST_DIR = dist -SRC_DIR = src -TEST_DIR = $(SRC_DIR)/common/test +UTILS_DIR = utils -ZIP_ARGS = -r -1 +.PHONY: all clean build -MOZILLA_INPUT = chrome.manifest install.rdf common firefox -CHROME_INPUT = manifest.json common chrome _locales - -.PHONY: all dirs chrome mozilla clean - -# Targets for creating directories -dirs: $(DIST_DIR) - rm -rf $(TEST_DIR) -$(DIST_DIR): - mkdir $(DIST_DIR) - -chrome: | dirs - rm -f $(DIST_DIR)/$(CHROME_PACKAGE_NAME); \ - cd $(SRC_DIR); \ - zip $(ZIP_ARGS) "../$(DIST_DIR)/$(CHROME_PACKAGE_NAME)" $(CHROME_INPUT) - -mozilla: | dirs - rm -f $(DIST_DIR)/$(MOZILLA_PACKAGE_NAME); \ - cd $(SRC_DIR); \ - zip $(ZIP_ARGS) "../$(DIST_DIR)/$(MOZILLA_PACKAGE_NAME)" $(MOZILLA_INPUT) - -#postbox: mozilla -# cp -f $(DIST_DIR)/$(MOZILLA_PACKAGE_NAME) $(DIST_DIR)/$(POSTBOX_PACKAGE_NAME) -# cd $(SRC_DIR)/postbox; \ -# zip $(ZIP_ARGS) ../../$(DIST_DIR)/$(POSTBOX_PACKAGE_NAME) common/* +build: | clean + cd $(UTILS_DIR); \ + node "build.js"; clean: rm -rf $(DIST_DIR) - find . -name "desktop.ini" -or -name ".*" -and -not -name "." -and -not -name ".git*" -print0 | xargs -0 rm -rf - git checkout -- $(TEST_DIR) -all: clean chrome mozilla +all: clean build diff --git a/make.sh b/make.sh deleted file mode 100644 index 07417284..00000000 --- a/make.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -PACKAGE_NAME=markdown-here -MOZILLA_PACKAGE_NAME=${PACKAGE_NAME}-mozilla.xpi -CHROME_PACKAGE_NAME=${PACKAGE_NAME}-chrome.zip -DIST_DIR=dist -SRC_DIR=src -TEST_DIR=${SRC_DIR}/common/test - -MOZILLA_INPUT="chrome.manifest install.rdf common firefox" -CHROME_INPUT="manifest.json common chrome _locales" - -ZIP_ARGS="-r -1" - -rm -rf "${DIST_DIR}" -rm -rf "${TEST_DIR}" -find . -name "desktop.ini" -or -name ".*" -and -not -name "." -and -not -name ".git*" -print0 | xargs -0 rm -rf - -mkdir ${DIST_DIR} - -cd ${SRC_DIR} - -zip ${ZIP_ARGS} "../${DIST_DIR}/${CHROME_PACKAGE_NAME}" ${CHROME_INPUT} - -zip ${ZIP_ARGS} "../${DIST_DIR}/${MOZILLA_PACKAGE_NAME}" ${MOZILLA_INPUT} - -cd - - -git checkout -- "${TEST_DIR}" diff --git a/utils/build.js b/utils/build.js index 845ba812..b8b97891 100644 --- a/utils/build.js +++ b/utils/build.js @@ -7,6 +7,7 @@ "use strict"; var fs = require('fs'); +var path = require('path'); var file = require('file'); var archiver = require('archiver'); var MetaScript = require('MetaScript'); @@ -17,11 +18,13 @@ var SRC_DIR = file.path.join(BASE_DIR, 'src'); var DIST_DIR = file.path.join(BASE_DIR, 'dist'); var CHROME_EXTENSION = file.path.join(DIST_DIR, 'chrome.zip'); var FIREFOX_EXTENSION = file.path.join(DIST_DIR, 'firefox.xpi'); -var CHROME_INPUT = ['manifest.json', 'common/', 'chrome/', '_locales/']; -var FIREFOX_INPUT = ['chrome.manifest', 'install.rdf', 'common/', 'firefox/']; +var CHROME_INPUT = [/^manifest\.json$/, /^common(\\|\/)/, /^chrome(\\|\/)/, /^_locales(\\|\/)/]; +var FIREFOX_INPUT = [/^chrome.manifest$/, /^install.rdf$/, /^common(\\|\/)/, /^firefox(\\|\/)/]; var FIREFOX_PLATFORM = 'mozilla'; -var skipFileRegexes = [/\.DS_Store$/, /.+\.bts$/]; +var skipFileRegexes = [/^common(\\|\/)test(\\|\/)/, + // OS files and temp files + /\.DS_Store$/, /.+\.bts$/, /desktop\.ini$/]; var javascriptFileRegex = /.+\.js$/; @@ -38,7 +41,7 @@ function fnameMatch(fpath, inputArray) { } for (i = 0; i < inputArray.length; i++) { - if (fname === inputArray[i] || fname.indexOf(inputArray[i]) === 0) { + if (inputArray[i].test(fname)) { return fname; } }