All your standard libraries will be assimilated into our JavaScript collective. Resistance is futile.
More info at: http://locutusjs.io/
npm install --save --save-exact locutus
For ease of development, we recommend these global installs:
npm install --global mocha babel-cli hexo
${EDITOR} try.js
var sprintf = require('locutus/php/strings/sprintf')
var echo = require('locutus/php/strings/echo')
var effectiveness = 'futile'
echo(sprintf('Resistance is %s', effectiveness))
var strings = require('locutus/golang/strings')
console.log(strings.Contains('Locutus', 'cut'))
$ node try.js
Resistance is futile
true
npm run test
Single out one function: natsort
TEST_GREP=natsort npm run test:languages
This first rewrites the test-cases which is useful if you're changing the tests themselves as well. If that's not needed as you're iterating purely on the implementation, here's a speedier way of singling out natsort
:
env DEBUG=locutus:* mocha \
--compilers js:babel-register \
--reporter spec \
test/languages/php/array/test-natsort.js
We keep the website in ./website
for so it's easy to keep docs & code in sync. For those reading this screaming murder, HashiCorp does this for all their projects, and it's working pretty well for them on a scale more impressive than ours.
Our website is built with Hexo.
To install the prerequisites type npm run website:install
.
Here's the flow that takes written functions to the website:
npm run website:inject
runssrc/_util/util.js
'sinjectweb
methodinjectweb
iterates over functions and parses them via the_load
and_parse
methods, specifically: the header comments that declare authors, tests, and dependenciesinjectweb
then writes each function towebsite/source
. The code is written as the content. The other parsed properties are prepended as YAML front matter- Jekyll uses
website/_layouts/function.html
as the layout template for the function collection, this determines how all the properties are rendered.
Blog posts can be found in website/source/_posts
.
If you want to preview locally type npm run website:start
.
Any change to master
is deployed automatically onto GitHub pages by Travis CI via the travis-deploy.sh
script.
Typing npm run deploy
in the root of the project takes care of all the building steps, and then force pushes the generated HTML to the gh-pages
branch of this repo.