Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Standalone typings are generated on build into the 'standalone-typings'
folder. The folder is contributed to the parser NPM package.
  • Loading branch information
KonstantinSviridov committed Oct 13, 2017
1 parent c97edb0 commit 925cb47
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ npm-debug.log
!/src/devUtil/documentation/theme.js

/dist/
/standalone-typings/

/coverage
coverage.zip
Expand Down
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/dist/search/test
/dist/topLevelGenerator

!/standalone-typings/

/documentation/*
!/documentation/images/
!/documentation/GettingStarted.md
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "dist/index.js",
"scripts": {
"compile": "rimraf dist && tsc",
"build": "npm run compile && npm run generateTopLevel && npm run generateTckSuite && npm run removeMainDTSLinks",
"build": "npm run compile && npm run generateTopLevel && npm run generateTckSuite && npm run removeMainDTSLinks && npm run extractTypings",
"generateTopLevel": "node dist/topLevelGenerator/buildParsers.js",
"generateTckSuite": "node dist/parser/test/scripts/generateTCKMocha.js && npm run compile",
"tck": "node dist/parser/test/scripts/launchTCKRepo.js",
Expand All @@ -20,7 +20,8 @@
"buildBrowserPublishNpm": "node generateBrowserVersion.js --type 'npm'",
"buildBrowserPublishBower": "node generateBrowserVersion.js --type 'bower'",
"validateTCKSchema": "node dist/parser/test/scripts/schema/schemaTCKValidator.js",
"platformTests": "node dist/parser/test/scripts/platformTests.js"
"platformTests": "node dist/parser/test/scripts/platformTests.js",
"extractTypings": "node ./dist/devUtil/extractTypings.js"
},
"dependencies": {
"base64url": "^2.0.0",
Expand Down
35 changes: 35 additions & 0 deletions src/devUtil/extractTypings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import fsutil = require("../util/fsutil");
import path = require("path");
import fs = require('fs');
import util = require("../util/index");


const rootPath = path.join(__dirname, "../../");
const npmIgnorePath = path.resolve(rootPath,".npmignore");
const npmIgnore = fs.readFileSync(npmIgnorePath,"utf-8");
const ignoredPaths = npmIgnore.split("\n").filter(x=>{
return util.stringStartsWith(x,"/dist");
}).map(x=>x.substring(1));

const destination = path.resolve(rootPath,"standalone-typings");
const source = path.resolve(rootPath,"dist");

fsutil.removeDirSyncRecursive(destination);
fsutil.copyDirSyncRecursive(
destination,
source,null,
p=>{
let rel = path.relative(rootPath,p).replace(/\\/g,"/");
if(util.stringStartsWith(rel,"./")){
rel = rel.substring(2);
}
for(let ip of ignoredPaths){
if(util.stringStartsWith(rel,ip)){
return false;
}
}
if(!fs.lstatSync(p).isDirectory() && !util.stringEndsWith(rel,".d.ts")){
return false;
}
return true;
});
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"exclude": [
"node_modules",
"typings"
"typings",
"standalone-typings"
]
}

0 comments on commit 925cb47

Please sign in to comment.