-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert the postinstall script to .js for windows support
- Loading branch information
Showing
5 changed files
with
62 additions
and
25 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ package-lock.json | |
/output/ | ||
*.d.ts | ||
*.js | ||
!/scripts/*.js | ||
|
||
# TypeScript | ||
!/typings/**/*.d.ts |
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
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,58 @@ | ||
#!/usr/bin/env node | ||
/* eslint-disable */ | ||
var childProcess = require('child_process'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var node_modules = path.resolve(__dirname, '..', 'node_modules'); | ||
var temp_modules = node_modules + '.tmp'; | ||
// We set an environment flag to ensure that this script doesn't loop. | ||
var compiling_var = 'compiling:' + process.env.npm_package_name; | ||
|
||
// When installing directly from GitHub, we get the TypeScript source, but none | ||
// of the compiled JavaScript. | ||
function isCompiled() { | ||
// It will be. | ||
if (process.env[compiling_var]) return true; | ||
|
||
try { | ||
return !!require.resolve('.'); | ||
} catch (error) { | ||
return false; | ||
} | ||
} | ||
|
||
function isDirectory() { | ||
var fullPath = path.join.apply(path, arguments); | ||
try { | ||
return fs.statSync(fullPath).isDirectory(); | ||
} catch (error) { | ||
return false; | ||
} | ||
} | ||
|
||
// When installing directly from GitHub, we get the source, but none of the | ||
// compiled JavaScript. | ||
if (isCompiled()) return; | ||
|
||
// Install our dev dependencies (aka TypeScript) into a sandbox, so that we can | ||
// compile our code. | ||
if (isDirectory(node_modules)) { | ||
fs.renameSync(node_modules, temp_modules); | ||
} | ||
|
||
var runner = /yarn/i.test(process.env.npm_config_user_agent) ? 'yarn' : 'npm'; | ||
|
||
process.env[compiling_var] = 'true'; | ||
process.stdout.write('Compiling TypeScript sources… '); | ||
childProcess.execSync(runner + ' install'); | ||
childProcess.execSync(runner + ' run compile'); | ||
process.stdout.write('done\n'); | ||
|
||
// Sneaky, but rimraf is included as a devDependency. | ||
require('rimraf').sync(node_modules); | ||
|
||
// Restore any production dependencies. | ||
if (isDirectory(temp_modules)) { | ||
fs.renameSync(temp_modules, node_modules); | ||
} |
This file was deleted.
Oops, something went wrong.