-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d62f362
commit 0ef42b2
Showing
8 changed files
with
122 additions
and
19 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 |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
/output/ | ||
/.psci* | ||
/src/.webpack.js | ||
/.spago/ | ||
/.psc-ide-port |
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,14 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
Features: | ||
- Update to v0.15.0 and support es modules | ||
|
||
Breaking changes: | ||
- `discover` now needs `MonadAff` constraint instead of `MonadEffect` due to dynamic imports returning promises |
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,24 @@ | ||
{ | ||
"name": "purescript-spec-discovery", | ||
"version": "1.0.0", | ||
"description": "purescript-spec-discovery is an extension to [purescript-spec](https://github.com/purescript-spec/purescript-spec) that finds specs automatically, given a regular expression pattern.", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/working-group-purescript-es/purescript-spec-discovery.git" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/working-group-purescript-es/purescript-spec-discovery/issues" | ||
}, | ||
"homepage": "https://github.com/working-group-purescript-es/purescript-spec-discovery#readme", | ||
"type": "module" | ||
} |
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,24 @@ | ||
let upstream = | ||
https://raw.githubusercontent.com/purescript/package-sets/prepare-0.15/src/packages.dhall | ||
sha256:5f32c078b014909642302b328bd9bebcdcedc301956a709b302f19521680a0aa | ||
|
||
in upstream | ||
with metadata.version = "v0.15.0-alpha-02" | ||
with spec = | ||
{ repo = "https://github.com/purescript-spec/purescript-spec.git" | ||
, version = "master" | ||
, dependencies = | ||
[ "aff" | ||
, "ansi" | ||
, "avar" | ||
, "console" | ||
, "exceptions" | ||
, "foldable-traversable" | ||
, "fork" | ||
, "now" | ||
, "pipes" | ||
, "prelude" | ||
, "strings" | ||
, "transformers" | ||
] | ||
} |
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,27 @@ | ||
{- | ||
Welcome to a Spago project! | ||
You can edit this file as you like. | ||
Need help? See the following resources: | ||
- Spago documentation: https://github.com/purescript/spago | ||
- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html | ||
When creating a new Spago project, you can use | ||
`spago init --no-comments` or `spago init -C` | ||
to generate this file without the comments in this block. | ||
-} | ||
{ name = "spec-discovery" | ||
, dependencies = | ||
[ "aff" | ||
, "aff-promise" | ||
, "arrays" | ||
, "console" | ||
, "effect" | ||
, "foldable-traversable" | ||
, "node-fs" | ||
, "prelude" | ||
, "spec" | ||
] | ||
, packages = ./packages.dhall | ||
, sources = [ "src/**/*.purs", "test/**/*.purs" ] | ||
} |
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,24 +1,30 @@ | ||
'use strict'; | ||
import path from "path" | ||
import fs from 'fs'; | ||
import { fileURLToPath } from "url" | ||
|
||
if (typeof require !== 'function') { | ||
throw new Error('Sorry, purescript-spec-discovery only supports NodeJS environments!'); | ||
} | ||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = path.dirname(__filename) | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
if (import.meta.url === `file://${process.argv[1]}`) { | ||
throw new Error('Sorry, purescript-spec-discovery only supports NodeJS environments!'); | ||
} | ||
|
||
function getMatchingModules(pattern) { | ||
var directories = fs.readdirSync(path.join(__dirname, '..')); | ||
return directories.filter(function (directory) { | ||
const modulePromises = directories.filter(function (directory) { | ||
return (new RegExp(pattern).test(directory)); | ||
}).map(function (name) { | ||
var module = require(path.join(__dirname, '..', name)); | ||
return (module && typeof module.spec !== 'undefined') ? module.spec : null; | ||
}).filter(function (x) { return x; }); | ||
var modulePromise = import(path.join(__dirname, '..', name, 'index.js')); | ||
return modulePromise.then( module => { | ||
return (module && typeof module.spec !== 'undefined') ? module.spec : null; | ||
}) | ||
}) | ||
const modules = Promise.all(modulePromises) | ||
return modules.then(ms => ms.filter(function (x) { return x; })); | ||
} | ||
|
||
exports.getSpecs = function (pattern) { | ||
export function getSpecs(pattern) { | ||
return function () { | ||
return getMatchingModules(pattern); | ||
}; | ||
}; | ||
} |
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
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