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

Adding the require-path option for psc #47

Merged
merged 1 commit into from
Jul 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ Toggles `--main` or sets `--main=<string>` that generates code to run the `main`

Sets `--browser-namespace=<string>` that specifies the namespace that PureScript modules will be exported to when running in the browser.

###### `requirePath` (String)

Sets `--require-path=<string>` that specifies the path prefix to use for `require()` calls in the generated JavaScript.

### `purescript.pscDocs(options)`

Invokes the `psc-docs` command. The following options are supported.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
],
"dependencies": {
"async": "^1.3.0",
"camelcase": "^1.1.0",
"cross-spawn": "^0.4.0",
"glob": "^5.0.5",
"gulp-util": "^3.0.4",
Expand Down
40 changes: 24 additions & 16 deletions src/Options.purs
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,35 @@ srcKey = "src"

noOptsOpt = "no-opts"

noOptsKey = "noOpts"
noOptsKey = camelcase noOptsOpt

noMagicDoOpt = "no-magic-do"

noMagicDoKey = "noMagicDo"
noMagicDoKey = camelcase noMagicDoOpt

noTcoOpt = "no-tco"

noTcoKey = "noTco"

verboseErrorsOpt = "verbose-errors"

verboseErrorsKey = "verboseErrors"
verboseErrorsKey = camelcase verboseErrorsOpt

outputOpt = "output"

outputKey = outputOpt

browserNamespaceOpt = "browser-namespace"

browserNamespaceKey = "browserNamespace"
browserNamespaceKey = camelcase browserNamespaceOpt

commentsOpt = "comments"

commentsKey = commentsOpt

noPrefixOpt = "no-prefix"

noPrefixKey = "noPrefix"
noPrefixKey = camelcase noPrefixOpt

mainOpt = "main"

Expand All @@ -74,6 +74,10 @@ docgenOpt = "docgen"

docgenKey = docgenOpt

requirePathOpt = "require-path"

requirePathKey = camelcase requirePathOpt

newtype Psc
= Psc { src :: Either String [String]
, ffi :: NullOrUndefined (Either String [String])
Expand All @@ -84,6 +88,7 @@ newtype Psc
, verboseErrors :: NullOrUndefined Boolean
, comments :: NullOrUndefined Boolean
, noPrefix :: NullOrUndefined Boolean
, requirePath :: NullOrUndefined String
}

newtype PscBundle
Expand Down Expand Up @@ -126,6 +131,7 @@ instance isForeignPsc :: IsForeign Psc where
, verboseErrors: _
, comments: _
, noPrefix: _
, requirePath: _
} <$> readProp srcKey obj
<*> readProp ffiKey obj
<*> readProp outputKey obj
Expand All @@ -134,7 +140,8 @@ instance isForeignPsc :: IsForeign Psc where
<*> readProp noOptsKey obj
<*> readProp verboseErrorsKey obj
<*> readProp commentsKey obj
<*> readProp noPrefixKey obj)
<*> readProp noPrefixKey obj
<*> readProp requirePathKey obj)

instance isForeignPscBundle :: IsForeign PscBundle where
read obj =
Expand Down Expand Up @@ -238,7 +245,8 @@ pscOptions opts = fold <$> parsed
opt noOptsOpt a.noOpts <>
opt verboseErrorsOpt a.verboseErrors <>
opt commentsOpt a.comments <>
opt noPrefixOpt a.noPrefix
opt noPrefixOpt a.noPrefix <>
opt requirePathOpt a.requirePath

pscBundleOptions :: Foreign -> Either ForeignError [String]
pscBundleOptions opts = fold <$> parsed
Expand All @@ -256,12 +264,12 @@ pscDocsOptions opts = fold <$> parsed
opt formatOpt a.format <>
opt docgenOpt a.docgen

foreign import expandGlob
"""
var expandGlob = (function () {
var glob = require("glob");
return function (pattern) {
return glob.sync(pattern);
};
}());
""" :: String -> [String]
foreign import expandGlob """
function expandGlob() {
var glob = require("glob");
return function(pattern) {
return glob.sync(pattern);
};
}""" :: String -> [String]

foreign import camelcase "function camelcase(a){return require('camelcase')(a);}" :: String -> String